-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix using global gemset's Rake gem #4
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9bb55c1
Ensure we search global gemsets for the rake gem, and update path acc…
bklang 3a2fc8e
Make sure the global path is added in addition to the gemset path
bklang 9a52962
Ensure we include the Ruby bin path (needed by JRuby)
bklang 31fc285
Remove debugging; don't check for existing path
bklang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,21 +44,51 @@ public static RubyInstallation[] getRvmRubies(Rvm rvm) { | |
FilePath global = getGlobal(name, gemsPath); | ||
|
||
for (FilePath gemCandidate : gems) { | ||
FilePath specifications = getSpecifications(gemCandidate, global); | ||
String newpath = ""; | ||
FilePath specifications = getSpecifications(gemCandidate); | ||
if (specifications != null) { | ||
Collection<FilePath> specs = specifications.list(rakeFilter); | ||
if (specs == null || specs.size() == 0) { | ||
// We did not find the rake gem in this gemset's bin directory; check in global | ||
specifications = getSpecifications(global); | ||
if (specifications != null) { | ||
specs = specifications.list(rakeFilter); | ||
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"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (specs != null && specs.size() > 0) { | ||
String path = new File(candidate.toURI()).getCanonicalPath(); | ||
RubyInstallation ruby = new RubyInstallation(gemCandidate.getName(), path); | ||
String path = new File(candidate.toURI()).getCanonicalPath(); | ||
RubyInstallation ruby = new RubyInstallation(gemCandidate.getName(), path); | ||
|
||
ruby.setGemHome(new File(gemCandidate.toURI()).getCanonicalPath()); | ||
ruby.setGemPath(buildGemPath(ruby.getGemHome(), global, gems)); | ||
ruby.setBinPath(new File(ruby.getGemHome(), "bin").getCanonicalPath()); | ||
ruby.setGemHome(new File(gemCandidate.toURI()).getCanonicalPath()); | ||
ruby.setGemPath(buildGemPath(ruby.getGemHome(), global, gems)); | ||
|
||
rubies.add(ruby); | ||
} | ||
// Add RVM Ruby path | ||
if (newpath.length() > 0) { | ||
newpath = newpath.concat(File.pathSeparator); | ||
} | ||
newpath = newpath.concat(rubiesPath.getRemote() + File.separator + name + File.separator + "bin"); | ||
|
||
// Add GEM bin directory to path | ||
newpath = newpath.concat(File.pathSeparator).concat(new File(ruby.getGemHome(), "bin").getCanonicalPath()); | ||
|
||
// Create or append the calculated path for this Ruby install | ||
path = ruby.getBinPath(); | ||
if (path == null || path.length() == 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this condition is not actually needed because you never set the bin path before. |
||
path = newpath; | ||
} else { | ||
path = path.concat(File.pathSeparator).concat(newpath); | ||
} | ||
ruby.setBinPath(path); | ||
|
||
rubies.add(ruby); | ||
} | ||
|
||
} | ||
|
@@ -93,9 +123,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(); | ||
} | ||
|
||
|
@@ -110,14 +142,11 @@ private static FilePath getGlobal(String name, FilePath gemsPath) | |
return global; | ||
} | ||
|
||
private static FilePath getSpecifications(FilePath candidate, FilePath global) | ||
private static FilePath getSpecifications(FilePath candidate) | ||
throws InterruptedException, IOException { | ||
FilePath specification = candidate.child("specifications"); | ||
if (specification.exists()) { | ||
return specification; | ||
} else if (global != null && global.exists() && | ||
global.child("specifications").exists()) { | ||
return global.child("specifications"); | ||
} | ||
return null; | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ben could you remove all these logging lines?