Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 61ac7f39330a
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7f2ab51687bf
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jun 8, 2015

  1. Copy the full SHA
    d578865 View commit details
  2. Copy the full SHA
    7f2ab51 View commit details
Showing with 17 additions and 3 deletions.
  1. +14 −1 core/src/main/java/org/jruby/RubyInstanceConfig.java
  2. +3 −2 spec/java_integration/rubygems/rubygems_spec.rb
15 changes: 14 additions & 1 deletion core/src/main/java/org/jruby/RubyInstanceConfig.java
Original file line number Diff line number Diff line change
@@ -60,6 +60,7 @@
import java.io.PrintStream;
import java.math.BigDecimal;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -670,7 +671,19 @@ public Map getEnvironment() {
// the assumption that if JRubyHome is not a regular file that java.class.path
// is the one which launched jruby is probably wrong. but is sufficient for
// java -jar jruby-complete.jar
environment.put("RUBY", "java -cp " + System.getProperty("java.class.path") + " org.jruby.Main");
StringBuilder command = new StringBuilder("java -cp ");
if (defaultClassLoader() instanceof URLClassLoader) {
for(URL url : ((URLClassLoader) defaultClassLoader()).getURLs()) {
if (url.getProtocol().equals("file")) {
command.append(File.pathSeparatorChar).append(url.getPath());
}
}
}
else {
command.append(File.pathSeparatorChar).append(SafePropertyAccessor.getProperty("java.class.path"));
}
command.append(" org.jruby.Main");
environment.put("RUBY", command.toString() );
}
return environment;
}
5 changes: 3 additions & 2 deletions spec/java_integration/rubygems/rubygems_spec.rb
Original file line number Diff line number Diff line change
@@ -17,16 +17,17 @@
url_paths = ["file:/var/tmp",
"http://jruby.org",
"classpath:/META-INF/jruby.home",
"uri:classpath:/META-INF/jruby.home",
"uri:classpath:/",
"uri:jar:file://META-INF/jruby.home!/some/path",
"jar:file:/var/tmp/some.jar!/some/path"]
Gem.use_paths(nil, url_paths)
Gem.path.should include(*url_paths)
Gem.path.should_not include("file", "http", "classpath", "jar")
Gem.path.should_not include("file", "http", "classpath", "jar", "uri", "classloader")
end

it "should not create gem subdirectories on a non-file: URL" do
Gem.ensure_gem_subdirectories("classpath:/bogus/classpath")
File.exist?("classpath:").should be_false
File.exist?("classpath:/bogus/classpath").should be_false
Gem.ensure_gem_subdirectories("file:")
File.exist?("file:").should be_false