Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Commit 1586fab

Browse files
committed
Fix: allow for binaries from $PATH to pass validity check
1 parent 7b6be11 commit 1586fab

File tree

1 file changed

+2
-6
lines changed
  • rust-analyzer/editors/code/src

1 file changed

+2
-6
lines changed

rust-analyzer/editors/code/src/util.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as lc from "vscode-languageclient";
2-
import * as fs from "fs";
32
import * as vscode from "vscode";
43
import { strict as nativeAssert } from "assert";
54
import { spawnSync } from "child_process";
@@ -114,15 +113,12 @@ export function isRustEditor(editor: vscode.TextEditor): editor is RustEditor {
114113
export function isValidExecutable(path: string): boolean {
115114
log.debug("Checking availability of a binary at", path);
116115

117-
if (!fs.existsSync(path)) return false;
118-
119116
const res = spawnSync(path, ["--version"], { encoding: 'utf8' });
120117

121-
const isSuccess = res.status === 0;
122-
const printOutput = isSuccess ? log.debug : log.warn;
118+
const printOutput = res.error && (res.error as any).code !== 'ENOENT' ? log.warn : log.debug;
123119
printOutput(path, "--version:", res);
124120

125-
return isSuccess;
121+
return res.status === 0;
126122
}
127123

128124
/** Sets ['when'](https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts) clause contexts */

0 commit comments

Comments
 (0)