Skip to content

Commit

Permalink
Make sure the global path is added in addition to the gemset path
Browse files Browse the repository at this point in the history
Also prevent adding an empty path separator at the front of the GEM PATH and add some debug lines to stdout
  • Loading branch information
bklang committed Mar 24, 2011
1 parent 9bb55c1 commit 3a2fc8e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/main/java/hudson/plugins/rake/Rake.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,15 @@ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListene
try {
EnvVars env = build.getEnvironment(listener);
if (rake != null) {
System.out.println("Rake GEM HOME: "+ rake.getGemHome());
if (rake.getGemHome() != null) {
env.put("GEM_HOME", rake.getGemHome());
}
System.out.println("Rake GEM PATH: "+ rake.getGemPath());
if (rake.getGemPath() != null) {
env.put("GEM_PATH", rake.getGemPath());
}
System.err.println("Rake Bin PATH: "+ rake.getBinPath());
if (rake.getBinPath() != null) {
StringBuilder builder = new StringBuilder();
String path = env.get("PATH");
Expand Down
20 changes: 14 additions & 6 deletions src/main/java/hudson/plugins/rake/RvmUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static RubyInstallation[] getRvmRubies(Rvm rvm) {
FilePath global = getGlobal(name, gemsPath);

for (FilePath gemCandidate : gems) {
String newpath = "";
FilePath specifications = getSpecifications(gemCandidate);
if (specifications != null) {
Collection<FilePath> specs = specifications.list(rakeFilter);
Expand All @@ -55,6 +56,9 @@ public static RubyInstallation[] getRvmRubies(Rvm rvm) {
if (specs == null || specs.size() == 0) {
// Rake not found in global either; this gemset is unusable
continue;
} else {
// Rake was found in the global gemset; include it in the path
newpath = global.getRemote().concat(File.separator).concat("bin");
}
}
}
Expand All @@ -66,13 +70,16 @@ public static RubyInstallation[] getRvmRubies(Rvm rvm) {
ruby.setGemHome(new File(gemCandidate.toURI()).getCanonicalPath());
ruby.setGemPath(buildGemPath(ruby.getGemHome(), global, gems));

String newpath = new File(ruby.getGemHome(), "bin").getCanonicalPath();
if (newpath.length() > 0) {
newpath = newpath.concat(File.pathSeparator);
}
newpath = newpath.concat(new File(ruby.getGemHome(), "bin").getCanonicalPath());
path = ruby.getBinPath();
if (path == null || path.length() == 0) {
path = new String();
path.concat(newpath);
path = path.concat(newpath);
} else {
path.concat(File.pathSeparator).concat(newpath);
path = path.concat(File.pathSeparator).concat(newpath);
}
ruby.setBinPath(path);

Expand Down Expand Up @@ -111,9 +118,11 @@ private static String buildGemPath(String currentGem, FilePath global, Collectio
}

for (String canonical : paths) {
path.append(File.pathSeparator).append(canonical);
if (path.length() > 0) {
path.append(File.pathSeparator);
}
path.append(canonical);
}

return path.toString();
}

Expand All @@ -131,7 +140,6 @@ private static FilePath getGlobal(String name, FilePath gemsPath)
private static FilePath getSpecifications(FilePath candidate)
throws InterruptedException, IOException {
FilePath specification = candidate.child("specifications");
System.err.println("Candidate: " + candidate);
if (specification.exists()) {
return specification;
}
Expand Down

0 comments on commit 3a2fc8e

Please sign in to comment.