mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-16 15:25:38 +00:00
Fix cargo not found on macos bug at vscode extension side
This commit is contained in:
parent
a78dd06951
commit
c9b395be2b
3 changed files with 48 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
|||
import * as lc from "vscode-languageclient";
|
||||
import * as vscode from "vscode";
|
||||
import { strict as nativeAssert } from "assert";
|
||||
import { spawnSync } from "child_process";
|
||||
|
||||
export function assert(condition: boolean, explanation: string): asserts condition {
|
||||
try {
|
||||
|
@ -82,3 +83,13 @@ export function isRustDocument(document: vscode.TextDocument): document is RustD
|
|||
export function isRustEditor(editor: vscode.TextEditor): editor is RustEditor {
|
||||
return isRustDocument(editor.document);
|
||||
}
|
||||
|
||||
export function isValidExecutable(path: string): boolean {
|
||||
log.debug("Checking availability of a binary at", path);
|
||||
|
||||
const res = spawnSync(path, ["--version"], { encoding: 'utf8' });
|
||||
|
||||
log.debug(res, "--version output:", res.output);
|
||||
|
||||
return res.status === 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue