ELECTRON_RUN_AS_NODE leaks into Bash tool on Windows, breaks Electron app launches
Bug
When using Claude Code as a VS Code/Cursor extension, ELECTRON_RUN_AS_NODE=1 is inherited from the extension host and passed through to every Bash tool invocation. This makes it impossible to launch Electron apps from the Bash tool because Electron sees the variable and runs as Node instead of launching the GUI.
Repro steps
- Open a project in Cursor (or VS Code)
- Open Claude Code
- Run any Bash command that checks the env:
````
env | grep ELECTRON
- Output:
ELECTRON_RUN_AS_NODE=1 - Try launching an Electron app from Bash - it runs as Node instead of GUI
What I found in the source
Extension side (extension.js, function bB):
function bB(K) {
let V = t0("environmentVariables") || [];
let B = {...process.env}; // copies ELECTRON_RUN_AS_NODE from extension host
// ...
return B;
}
NODE_OPTIONS is already cleaned (delete U.NODE_OPTIONS in the initialize function), but ELECTRON_RUN_AS_NODE is not.
CLI side (subprocessEnv function):
function Zx() {
let H = jZK?.() ?? {};
if (!lH(process.env.CLAUDE_CODE_SUBPROCESS_ENV_SCRUB))
return {...process.env, ...H}; // passes ELECTRON_RUN_AS_NODE through
let $ = {...process.env, ...H};
for (let q of e9f) delete $[q]; // scrub list only has secrets, not ELECTRON_RUN_AS_NODE
return $
}
Also, CLAUDE_ENV_FILE (the documented workaround) doesn't work on Windows:
if (L6() === "windows") return "Session environment not yet supported on Windows", null;
Expected behavior
ELECTRON_RUN_AS_NODE should be removed from the subprocess environment, same as NODE_OPTIONS already is. A one-liner fix in both bB() and subprocessEnv():
delete B.ELECTRON_RUN_AS_NODE;
Workaround
Adding unset ELECTRON_RUN_AS_NODE to ~/.bashrc works, but it shouldn't be necessary.
Environment
- Claude Code 2.1.87 (VS Code extension)
- Cursor 2.6.11 (VS Code fork)
- Windows 11 Pro
- Bash shell
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗