diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2023-08-12 07:10:20 +0200 |
|---|---|---|
| committer | Lukas Wirth <lukastw97@gmail.com> | 2023-08-12 07:10:20 +0200 |
| commit | 33f9250d2139fa00038736515b9e22c51c419c01 (patch) | |
| tree | 20d517fe359ff3d209b96674ca43043cd0e5f035 | |
| parent | 1b678231d71f48f078e1a80230c28a2fce2daec5 (diff) | |
| download | rust-33f9250d2139fa00038736515b9e22c51c419c01.tar.gz rust-33f9250d2139fa00038736515b9e22c51c419c01.zip | |
Pass server extraEnv to isValidExecutable
| -rw-r--r-- | editors/code/src/bootstrap.ts | 2 | ||||
| -rw-r--r-- | editors/code/src/util.ts | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/editors/code/src/bootstrap.ts b/editors/code/src/bootstrap.ts index ef4dff095cf..6cf399599d9 100644 --- a/editors/code/src/bootstrap.ts +++ b/editors/code/src/bootstrap.ts @@ -20,7 +20,7 @@ export async function bootstrap( log.info("Using server binary at", path); - if (!isValidExecutable(path)) { + if (!isValidExecutable(path, config.serverExtraEnv)) { if (config.serverPath) { throw new Error(`Failed to execute ${path} --version. \`config.server.path\` or \`config.serverPath\` has been set explicitly.\ Consider removing this config or making a valid server binary available at that path.`); diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index 38ce6761578..e5394525772 100644 --- a/editors/code/src/util.ts +++ b/editors/code/src/util.ts @@ -2,6 +2,7 @@ import * as vscode from "vscode"; import { strict as nativeAssert } from "assert"; import { exec, type ExecOptions, spawnSync } from "child_process"; import { inspect } from "util"; +import { Env } from "./client"; export function assert(condition: boolean, explanation: string): asserts condition { try { @@ -93,10 +94,13 @@ export function isDocumentInWorkspace(document: RustDocument): boolean { return false; } -export function isValidExecutable(path: string): boolean { +export function isValidExecutable(path: string, extraEnv: Env): boolean { log.debug("Checking availability of a binary at", path); - const res = spawnSync(path, ["--version"], { encoding: "utf8" }); + const res = spawnSync(path, ["--version"], { + encoding: "utf8", + env: { ...process.env, ...extraEnv }, + }); const printOutput = res.error ? log.warn : log.info; printOutput(path, "--version:", res); |
