Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default paths for rvm-auto-ruby #1864

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 46 additions & 6 deletions vscode/src/ruby/rvm.ts
Expand Up @@ -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",
Comment on lines +24 to +25
Copy link
Member

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?

Copy link

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.

image

I can't speak to installing in /usr/local/rvm, but I hope that helps.

];
// check if rvm-auto-ruby is in the PATH
try {
const pathCheck = await asyncExec("which rvm-auto-ruby");
Copy link
Member

Choose a reason for hiding this comment

The 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 PATH, but not installed in one of the other installation directories?

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
Expand Down