Skip to content

Commit c319a65

Browse files
authored
Point to local executable directly instead of modifying PATH (#3443)
1 parent ceb76ef commit c319a65

3 files changed

Lines changed: 8 additions & 63 deletions

File tree

vscode/src/client.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ function getLspExecutables(
137137
options: executableOptions,
138138
};
139139
} else {
140+
const workspacePath = workspaceFolder.uri.fsPath;
141+
const command =
142+
path.basename(workspacePath) === "ruby-lsp" && os.platform() !== "win32"
143+
? path.join(workspacePath, "exe", "ruby-lsp")
144+
: "ruby-lsp";
145+
140146
const args = [];
141147

142148
if (branch.length > 0) {
@@ -147,14 +153,9 @@ function getLspExecutables(
147153
args.push("--use-launcher");
148154
}
149155

150-
run = {
151-
command: "ruby-lsp",
152-
args,
153-
options: executableOptions,
154-
};
155-
156+
run = { command, args, options: executableOptions };
156157
debug = {
157-
command: "ruby-lsp",
158+
command,
158159
args: args.concat(["--debug"]),
159160
options: executableOptions,
160161
};

vscode/src/ruby.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,6 @@ export class Ruby implements RubyInterface {
193193
if (!this.error) {
194194
this.fetchRubyVersionInfo();
195195
await this.setupBundlePath();
196-
197-
// When working on the Ruby LSP itself, we want to use the local version of our executables rather than the ones
198-
// globally installed. That allows us to catch mistakes made in the launch process before they are released
199-
if (
200-
path.basename(this.workspaceFolder.uri.fsPath) === "ruby-lsp" &&
201-
os.platform() !== "win32"
202-
) {
203-
const localExecutablesUri = vscode.Uri.joinPath(
204-
this.workspaceFolder.uri,
205-
"exe",
206-
);
207-
208-
this._env.PATH = `${localExecutablesUri.fsPath}${path.delimiter}${this._env.PATH}`;
209-
}
210196
}
211197
}
212198

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

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable no-process-env */
22
import * as assert from "assert";
33
import * as path from "path";
4-
import os from "os";
54

65
import * as vscode from "vscode";
76
import sinon from "sinon";
@@ -175,47 +174,6 @@ suite("Ruby environment activation", () => {
175174
assert.deepStrictEqual(ruby.env, { BUNDLE_GEMFILE: ".ruby-lsp/Gemfile" });
176175
});
177176

178-
test("Adds local exe directory to PATH when working on the Ruby LSP itself", async () => {
179-
if (os.platform() === "win32") {
180-
// We don't mutate the path on Windows
181-
return;
182-
}
183-
184-
const manager = process.env.CI
185-
? ManagerIdentifier.None
186-
: ManagerIdentifier.Chruby;
187-
188-
const configStub = sinon
189-
.stub(vscode.workspace, "getConfiguration")
190-
.returns({
191-
get: (name: string) => {
192-
if (name === "rubyVersionManager") {
193-
return { identifier: manager };
194-
} else if (name === "bundleGemfile") {
195-
return "";
196-
}
197-
198-
return undefined;
199-
},
200-
} as unknown as vscode.WorkspaceConfiguration);
201-
202-
const workspacePath = path.dirname(
203-
path.dirname(path.dirname(path.dirname(__dirname))),
204-
);
205-
const lspFolder: vscode.WorkspaceFolder = {
206-
uri: vscode.Uri.file(workspacePath),
207-
name: path.basename(workspacePath),
208-
index: 0,
209-
};
210-
const ruby = new Ruby(context, lspFolder, outputChannel, FAKE_TELEMETRY);
211-
await ruby.activateRuby();
212-
213-
const firstEntry = ruby.env.PATH!.split(path.delimiter)[0];
214-
assert.match(firstEntry, /ruby-lsp\/exe$/);
215-
216-
configStub.restore();
217-
}).timeout(10000);
218-
219177
test("Ignores untrusted workspace for telemetry", async () => {
220178
const telemetry = { ...FAKE_TELEMETRY, logError: sinon.stub() };
221179
const ruby = new Ruby(context, workspaceFolder, outputChannel, telemetry);

0 commit comments

Comments
 (0)