Skip to content

Instantly share code, notes, and snippets.

@headius
Created November 4, 2010 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save headius/663018 to your computer and use it in GitHub Desktop.
Save headius/663018 to your computer and use it in GitHub Desktop.
diff --git a/src/org/jruby/RubyInstanceConfig.java b/src/org/jruby/RubyInstanceConfig.java
index fe27c63..9813666 100644
--- a/src/org/jruby/RubyInstanceConfig.java
+++ b/src/org/jruby/RubyInstanceConfig.java
@@ -832,27 +832,11 @@ public class RubyInstanceConfig {
// verify it if it's there
jrubyHome = verifyHome(jrubyHome);
} else {
- try {
- // try loading from classloader resources
- URI jrubyHomeURI = getClass().getResource("/META-INF/jruby.home").toURI();
- String scheme = jrubyHomeURI.getScheme();
- String path = jrubyHomeURI.getSchemeSpecificPart();
- if ("jar".equals(scheme) && path.startsWith("file:")) {
- // special case for jar:file (most typical case)
- jrubyHome = path;
- } else {
- jrubyHome = "classpath:/META-INF/jruby.home";
- return jrubyHome;
- }
- } catch (Exception e) {}
+ // try loading from classloader resources
+ jrubyHome = "classpath:/META-INF/jruby.home";
- if (jrubyHome != null) {
- // verify it if it's there
- jrubyHome = verifyHome(jrubyHome);
- } else {
- // otherwise fall back on system temp location
- jrubyHome = SafePropertyAccessor.getProperty("java.io.tmpdir");
- }
+ // verify it if it's there, falling back on tmpdir if not
+ jrubyHome = verifyHome(jrubyHome);
}
}
return jrubyHome;
@@ -865,18 +849,23 @@ public class RubyInstanceConfig {
// We require the home directory to be absolute
private String verifyHome(String home) {
if (home.equals(".")) {
- home = SafePropertyAccessor.getProperty("user.dir");
+ return SafePropertyAccessor.getProperty("user.dir");
}
+
if (home.startsWith("cp:")) {
- home = home.substring(3);
- } else if (!home.startsWith("file:") && !home.startsWith("classpath:")) {
+ return home.substring(3);
+ }
+
+ if (!home.startsWith("file:") && !home.startsWith("classpath:")) {
NormalizedFile f = new NormalizedFile(home);
if (!f.isAbsolute()) {
home = f.getAbsolutePath();
}
+
if (!f.exists()) {
- error.println("Warning: JRuby home \"" + f + "\" does not exist, using " + SafePropertyAccessor.getProperty("java.io.tmpdir"));
- return System.getProperty("java.io.tmpdir");
+ String tmpDir = SafePropertyAccessor.getProperty("java.io.tmpdir");
+ error.println("Warning: JRuby home \"" + f + "\" does not exist, using " + tmpDir);
+ return tmpDir;
}
}
return home;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment