Skip to content

Commit 54add89

Browse files
committed
Debug
1 parent bc11fbb commit 54add89

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

vscode/src/ruby/chruby.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class Chruby extends VersionManager {
6060
PATH: `${path.join(gemHome, "bin")}${path.delimiter}${path.join(
6161
defaultGems,
6262
"bin",
63-
)}${path.delimiter}${path.dirname(rubyUri.fsPath)}${path.delimiter}${process.env.PATH}`,
63+
)}${path.delimiter}${path.dirname(rubyUri.fsPath)}${path.delimiter}${this.getProcessPath()}`,
6464
};
6565

6666
return {
@@ -70,6 +70,19 @@ export class Chruby extends VersionManager {
7070
};
7171
}
7272

73+
protected getProcessPath() {
74+
return process.env.PATH;
75+
}
76+
77+
// Returns the full URI to the Ruby executable
78+
protected async findRubyUri(rubyVersion: RubyVersion): Promise<vscode.Uri> {
79+
if (/\d+\.\d+\.\d+/.exec(rubyVersion.version)) {
80+
return this.findRubyUriForCompleteVersion(rubyVersion);
81+
}
82+
83+
return this.findRubyUriWithOmittedPatch(rubyVersion);
84+
}
85+
7386
// Run the activation script using the Ruby installation we found so that we can discover gem paths
7487
protected async runActivationScript(rubyExecutableUri: vscode.Uri): Promise<{
7588
defaultGems: string;
@@ -105,15 +118,6 @@ export class Chruby extends VersionManager {
105118
return this.parseWithErrorHandling(result.stderr);
106119
}
107120

108-
// Returns the full URI to the Ruby executable
109-
protected async findRubyUri(rubyVersion: RubyVersion): Promise<vscode.Uri> {
110-
if (/\d+\.\d+\.\d+/.exec(rubyVersion.version)) {
111-
return this.findRubyUriForCompleteVersion(rubyVersion);
112-
}
113-
114-
return this.findRubyUriWithOmittedPatch(rubyVersion);
115-
}
116-
117121
private async findRubyUriWithOmittedPatch(
118122
rubyVersion: RubyVersion,
119123
): Promise<vscode.Uri> {

vscode/src/ruby/rubyInstaller.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-process-env */
12
import os from "os";
23

34
import * as vscode from "vscode";
@@ -16,6 +17,12 @@ interface RubyVersion {
1617
//
1718
// If we can't find it there, then we throw an error and rely on the user to manually select where Ruby is installed.
1819
export class RubyInstaller extends Chruby {
20+
// Environment variables are case sensitive on Windows when we access them through NodeJS. We need to ensure that
21+
// we're searching through common variations, so that we don't accidentally miss the path we should inherit
22+
protected getProcessPath() {
23+
return process.env.Path ?? process.env.PATH ?? process.env.path;
24+
}
25+
1926
// Returns the full URI to the Ruby executable
2027
protected async findRubyUri(rubyVersion: RubyVersion): Promise<vscode.Uri> {
2128
const [major, minor, _patch] = rubyVersion.version.split(".").map(Number);

vscode/src/test/suite/ruby/rubyInstaller.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ suite("RubyInstaller", () => {
6060
const windows = new RubyInstaller(workspaceFolder, outputChannel);
6161
const { env, version, yjit } = await windows.activate();
6262

63-
assert.match(env.GEM_PATH!, /ruby\/3\.3\.0/);
64-
assert.match(env.GEM_PATH!, /lib\/ruby\/gems\/3\.3\.0/);
63+
assert.match(env.GEM_PATH!, /lib\\ruby\\gems\\3\.3\.0/);
6564
assert.strictEqual(version, RUBY_VERSION);
6665
assert.notStrictEqual(yjit, undefined);
6766

@@ -90,8 +89,7 @@ suite("RubyInstaller", () => {
9089
const windows = new RubyInstaller(workspaceFolder, outputChannel);
9190
const { env, version, yjit } = await windows.activate();
9291

93-
assert.match(env.GEM_PATH!, /ruby\/3\.3\.0/);
94-
assert.match(env.GEM_PATH!, /lib\/ruby\/gems\/3\.3\.0/);
92+
assert.match(env.GEM_PATH!, /lib\\ruby\\gems\\3\.3\.0/);
9593
assert.strictEqual(version, RUBY_VERSION);
9694
assert.notStrictEqual(yjit, undefined);
9795

0 commit comments

Comments
 (0)