-
Notifications
You must be signed in to change notification settings - Fork 141
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 default paths for rvm-auto-ruby
#1864
Closed
Closed
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,13 +19,53 @@ export class Rvm extends VersionManager { | |
".to_json)", | ||
].join(""); | ||
|
||
const result = await asyncExec( | ||
`${path.join(os.homedir(), ".rvm", "bin", "rvm-auto-ruby")} -W0 -rjson -e '${activationScript}'`, | ||
{ | ||
cwd: this.bundleUri.fsPath, | ||
}, | ||
); | ||
const basePaths = [ | ||
path.join(os.homedir(), ".rvm", "bin"), | ||
"/usr/local/rvm/bin", | ||
"/usr/share/rvm/bin", | ||
]; | ||
// check if rvm-auto-ruby is in the PATH | ||
try { | ||
const pathCheck = await asyncExec("which rvm-auto-ruby"); | ||
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. Similar to my previous question, what scenario leads to RVM being in the |
||
this.outputChannel.info(`Output check: ${pathCheck.stdout}`); | ||
if (pathCheck.stdout.includes("rvm-auto-ruby")) { | ||
// rvm-auto-ruby is in the PATH variable | ||
basePaths.unshift(""); | ||
} | ||
} catch (error) { | ||
const pathOutput = await asyncExec("echo $PATH"); | ||
this.outputChannel.info( | ||
`Could not find rvm-auto-ruby on PATH: ${error}, current PATH: ${pathOutput.stdout}`, | ||
); | ||
} | ||
|
||
let result = { stderr: "" }; | ||
for (const basePath of basePaths) { | ||
try { | ||
const resultOfPath = await asyncExec( | ||
`${path.join(basePath, "rvm-auto-ruby")} -W0 -rjson -e '${activationScript}'`, | ||
{ | ||
cwd: this.bundleUri.fsPath, | ||
}, | ||
); | ||
result = resultOfPath; | ||
this.outputChannel.info( | ||
`Activated rvm env with this path: ${path.join(basePath, "rvm-auto-ruby")}`, | ||
); | ||
break; | ||
} catch (error) { | ||
this.outputChannel.info( | ||
`Checking if we can activate rvm env with this path: ${path.join(basePath, "rvm-auto-ruby")}`, | ||
); | ||
} | ||
} | ||
|
||
if (result.stderr === "") { | ||
this.outputChannel.error( | ||
`Could not activate rvm based environment with these paths: ${basePaths.join(", ")}`, | ||
); | ||
return { error: true }; | ||
} | ||
const parsedResult = JSON.parse(result.stderr); | ||
|
||
// Invoking `rvm-auto-ruby` doesn't actually inject anything into the environment, it just finds the right Ruby to | ||
|
Oops, something went wrong.
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.
Can you describe when RVM ends up installed in these directories? I assume one of those is the default for Linux, but why is there two?
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.
Hello, I opened #1862. I installed RVM on Ubuntu with this package per the instructions on the official RVM site. This package only installs RVM in
/usr/share/rvm
.I can't speak to installing in
/usr/local/rvm
, but I hope that helps.