summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Landaeta <nomadium@debian.org>2019-02-26 10:24:15 +0100
committerAndrej Shadura <andrewsh@debian.org>2019-02-26 10:24:15 +0100
commit9dd83224d62687eae29d56a33982c5d4cea21a0e (patch)
tree8e2d52e6a6214fc95803c08ecd1d12459d769a46
parent9ac88c11f84cd56b7f33105965aeb77a4c861b88 (diff)
Add /usr/lib/ruby/vendor_ruby to default LOAD_PATH
Bug-Debian: https://bugs.debian.org/663342 Forwarded: no Last-Update: 2017-03-08 Gbp-Pq: Name 0007-Add-usr-lib-ruby-vendor-ruby-to-load-path.patch
-rwxr-xr-xbin/jruby.bash1
-rw-r--r--core/src/main/java/org/jruby/ext/rbconfig/RbConfigLibrary.java8
-rw-r--r--core/src/main/java/org/jruby/runtime/load/LoadService.java6
3 files changed, 15 insertions, 0 deletions
diff --git a/bin/jruby.bash b/bin/jruby.bash
index 610404d2e..3e0f72509 100755
--- a/bin/jruby.bash
+++ b/bin/jruby.bash
@@ -419,6 +419,7 @@ else
"-Djruby.home=$JRUBY_HOME" \
"-Djruby.lib=$JRUBY_HOME/lib" -Djruby.script=jruby \
"-Djruby.shell=$JRUBY_SHELL" \
+ "-Ddebian.include.mri_vendor_libdir_in_load_path=true" \
$java_class $mode "$@"
fi
fi
diff --git a/core/src/main/java/org/jruby/ext/rbconfig/RbConfigLibrary.java b/core/src/main/java/org/jruby/ext/rbconfig/RbConfigLibrary.java
index 1690b89d0..8f5c56c81 100644
--- a/core/src/main/java/org/jruby/ext/rbconfig/RbConfigLibrary.java
+++ b/core/src/main/java/org/jruby/ext/rbconfig/RbConfigLibrary.java
@@ -65,6 +65,8 @@ public class RbConfigLibrary implements Library {
private static final String RUBY_FREEBSD = "freebsd";
private static final String RUBY_AIX = "aix";
+ private static final String MRI_VENDOR_LIBDIR = "/usr/lib/ruby/vendor_ruby";
+
private static String normalizedHome;
/** This is a map from Java's "friendly" OS names to those used by Ruby */
@@ -186,6 +188,10 @@ public class RbConfigLibrary implements Library {
return newFile(getRubyLibDir(runtime), "vendor_ruby").getPath();
}
+ public static String getMRIVendorLibDir(Ruby runtime) {
+ return SafePropertyAccessor.getProperty("debian.mri.vendor.libdir", MRI_VENDOR_LIBDIR);
+ }
+
public static String getVendorLibDir(Ruby runtime) {
return getVendorDir(runtime);
}
@@ -294,6 +300,7 @@ public class RbConfigLibrary implements Library {
String rubyLibDir = getRubyLibDir(runtime);
String archDir = getArchDir(runtime);
String vendorDir = getVendorDir(runtime);
+ String vendorMRILibDir = getMRIVendorLibDir(runtime);
String vendorLibDir = getVendorLibDir(runtime);
String vendorArchDir = getVendorArchDir(runtime);
String siteDir = getSiteDir(runtime);
@@ -310,6 +317,7 @@ public class RbConfigLibrary implements Library {
setConfig(configHash, "vendorlibdir", vendorLibDir);
setConfig(configHash, "vendorarchdir", vendorArchDir);
}
+ setConfig(configHash, "mri_vendor_libdir", vendorMRILibDir);
setConfig(configHash, "sitedir", siteDir);
setConfig(configHash, "sitelibdir", siteLibDir);
setConfig(configHash, "sitearchdir", siteArchDir);
diff --git a/core/src/main/java/org/jruby/runtime/load/LoadService.java b/core/src/main/java/org/jruby/runtime/load/LoadService.java
index 0067fc37c..f8db864bc 100644
--- a/core/src/main/java/org/jruby/runtime/load/LoadService.java
+++ b/core/src/main/java/org/jruby/runtime/load/LoadService.java
@@ -71,6 +71,7 @@ import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.FileResource;
import org.jruby.util.JRubyFile;
+import org.jruby.util.SafePropertyAccessor;
import org.jruby.util.collections.StringArraySet;
import org.jruby.util.log.Logger;
import org.jruby.util.log.LoggerFactory;
@@ -253,6 +254,11 @@ public class LoadService {
addPath(RbConfigLibrary.getRubyLibDir(runtime));
}
+ // Allow jruby to load libraries installed in the system
+ if (SafePropertyAccessor.getBoolean("debian.include.mri_vendor_libdir_in_load_path", false)) {
+ addPath(RbConfigLibrary.getMRIVendorLibDir(runtime));
+ }
+
} catch(SecurityException ignore) {}
addPaths(runtime.getInstanceConfig().getExtraLoadPaths());
}