diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-06 11:56:22 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-06 11:56:22 +0100 |
commit | a5ae50400dbab3f176a640570d336dae91d4e16e (patch) | |
tree | 276513ea550ae27a284321e3f35b2ff46f545f1d /editors/code/src | |
parent | a0f24455ddc474ee288849b79aa1fc8ca7829385 (diff) | |
parent | ef223b9e6439c228e0be49861efd2067c0b22af4 (diff) |
Merge #5234
5234: Fix: allow for binaries from $PATH to pass validity check r=matklad a=Veetaha
Tackles https://github.com/rust-analyzer/rust-analyzer/pull/5229#issuecomment-654151387
cc @matklad @lnicola
Apparently `fs.existsSync()` works only with real paths and not with `$PATH` env var
Co-authored-by: Veetaha <[email protected]>
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/util.ts | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index 78fe6f5da..970fedb37 100644 --- a/editors/code/src/util.ts +++ b/editors/code/src/util.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | import * as lc from "vscode-languageclient"; | 1 | import * as lc from "vscode-languageclient"; |
2 | import * as fs from "fs"; | ||
3 | import * as vscode from "vscode"; | 2 | import * as vscode from "vscode"; |
4 | import { strict as nativeAssert } from "assert"; | 3 | import { strict as nativeAssert } from "assert"; |
5 | import { spawnSync } from "child_process"; | 4 | import { spawnSync } from "child_process"; |
@@ -114,15 +113,12 @@ export function isRustEditor(editor: vscode.TextEditor): editor is RustEditor { | |||
114 | export function isValidExecutable(path: string): boolean { | 113 | export function isValidExecutable(path: string): boolean { |
115 | log.debug("Checking availability of a binary at", path); | 114 | log.debug("Checking availability of a binary at", path); |
116 | 115 | ||
117 | if (!fs.existsSync(path)) return false; | ||
118 | |||
119 | const res = spawnSync(path, ["--version"], { encoding: 'utf8' }); | 116 | const res = spawnSync(path, ["--version"], { encoding: 'utf8' }); |
120 | 117 | ||
121 | const isSuccess = res.status === 0; | 118 | const printOutput = res.error && (res.error as any).code !== 'ENOENT' ? log.warn : log.debug; |
122 | const printOutput = isSuccess ? log.debug : log.warn; | ||
123 | printOutput(path, "--version:", res); | 119 | printOutput(path, "--version:", res); |
124 | 120 | ||
125 | return isSuccess; | 121 | return res.status === 0; |
126 | } | 122 | } |
127 | 123 | ||
128 | /** Sets ['when'](https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts) clause contexts */ | 124 | /** Sets ['when'](https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts) clause contexts */ |