Skip to content

Commit 9feb15e

Browse files
Merge #4669
4669: Always derive from `process.env` when spawning a child process/shell execution r=matklad a=Dfinity-Alin This is useful when an extension (e.g. [Nix Environment Selector](https://marketplace.visualstudio.com/items?itemName=arrterian.nix-env-selector)) or [launch configuration](https://stackoverflow.com/questions/57641460/set-env-var-for-node-js-when-launching-through-vs-code) sets one or more environment variables. When `env` is not explicitly specified in the options passed to `child_process.spawn()` or `vscode.ShellExecution()`, then `process.env` gets applied automatically. But when an explicit `env` is set, it should inherit from `process.env` rather than replace it completely. Co-authored-by: Alin Sinpalean <[email protected]>
2 parents c575da1 + 771457e commit 9feb15e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

editors/code/src/run.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export function createTask(spec: ra.Runnable): vscode.Task {
177177
label: spec.label,
178178
command: spec.bin,
179179
args: spec.extraArgs ? [...spec.args, '--', ...spec.extraArgs] : spec.args,
180-
env: spec.env,
180+
env: Object.assign({}, process.env, spec.env),
181181
};
182182

183183
const execOption: vscode.ShellExecutionOptions = {

0 commit comments

Comments
 (0)