mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Missing runnable env on debug target
Fix bug in Rust Analyzer where runnable debugging did not pass environment variable from configuration to child process of Cargo on binary build stage
This commit is contained in:
parent
17e31b7d3b
commit
fb9a1dd87e
@ -118,8 +118,8 @@ async function getDebugConfiguration(
|
|||||||
return path.normalize(p).replace(wsFolder, "${workspaceFolder" + workspaceQualifier + "}");
|
return path.normalize(p).replace(wsFolder, "${workspaceFolder" + workspaceQualifier + "}");
|
||||||
}
|
}
|
||||||
|
|
||||||
const executable = await getDebugExecutable(runnable);
|
|
||||||
const env = prepareEnv(runnable, ctx.config.runnableEnv);
|
const env = prepareEnv(runnable, ctx.config.runnableEnv);
|
||||||
|
const executable = await getDebugExecutable(runnable, env);
|
||||||
let sourceFileMap = debugOptions.sourceFileMap;
|
let sourceFileMap = debugOptions.sourceFileMap;
|
||||||
if (sourceFileMap === "auto") {
|
if (sourceFileMap === "auto") {
|
||||||
// let's try to use the default toolchain
|
// let's try to use the default toolchain
|
||||||
@ -156,8 +156,11 @@ async function getDebugConfiguration(
|
|||||||
return debugConfig;
|
return debugConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getDebugExecutable(runnable: ra.Runnable): Promise<string> {
|
async function getDebugExecutable(
|
||||||
const cargo = new Cargo(runnable.args.workspaceRoot || ".", debugOutput);
|
runnable: ra.Runnable,
|
||||||
|
env: Record<string, string>
|
||||||
|
): Promise<string> {
|
||||||
|
const cargo = new Cargo(runnable.args.workspaceRoot || ".", debugOutput, env);
|
||||||
const executable = await cargo.executableFromArgs(runnable.args.cargoArgs);
|
const executable = await cargo.executableFromArgs(runnable.args.cargoArgs);
|
||||||
|
|
||||||
// if we are here, there were no compilation errors.
|
// if we are here, there were no compilation errors.
|
||||||
|
@ -18,7 +18,11 @@ export interface ArtifactSpec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Cargo {
|
export class Cargo {
|
||||||
constructor(readonly rootFolder: string, readonly output: vscode.OutputChannel) {}
|
constructor(
|
||||||
|
readonly rootFolder: string,
|
||||||
|
readonly output: vscode.OutputChannel,
|
||||||
|
readonly env: Record<string, string>
|
||||||
|
) {}
|
||||||
|
|
||||||
// Made public for testing purposes
|
// Made public for testing purposes
|
||||||
static artifactSpec(args: readonly string[]): ArtifactSpec {
|
static artifactSpec(args: readonly string[]): ArtifactSpec {
|
||||||
@ -102,6 +106,7 @@ export class Cargo {
|
|||||||
const cargo = cp.spawn(path, cargoArgs, {
|
const cargo = cp.spawn(path, cargoArgs, {
|
||||||
stdio: ["ignore", "pipe", "pipe"],
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
cwd: this.rootFolder,
|
cwd: this.rootFolder,
|
||||||
|
env: this.env,
|
||||||
});
|
});
|
||||||
|
|
||||||
cargo.on("error", (err) => reject(new Error(`could not launch cargo: ${err}`)));
|
cargo.on("error", (err) => reject(new Error(`could not launch cargo: ${err}`)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user