ConEmu build: 170402 x64
OS version: Windows 10 version 1703 x64
Used shell version git-bash: v2.11.0
When executing a process which spawns a child process, which in turn creates another child process, the empty environment variables are passed through as 'undefined'.
git clone [email protected]:nicojs/reproduce-conemu-child-process-environment-bug.gitnpm install.npm testWhen ran from within ConEmu: the test failes
1) the env should contain "npm_config_onload_script":
Error: "npm_config_onload_script": "undefined"!"
The test also prints the environment variables to screen. You can see a lot of "undefined" values (the string literal, not an absent value).
For example: "npm_config_onload_script": "undefined",
If ran from cmd or git-bash using mintty directly: the test passes
√ should contain "npm_config_onload_script"
If you now look at the environment variables on screen, you don't see the "undefined" values. Just empty strings.
For example: "npm_config_onload_script": "",
If ran from cmd or git-bash using mintty
THIS is NOT fair comparison. ConEmu doesn't ruin node. From your screenshots I can make a conclusion you run bash. Report this to your bash bundle authors.
Third-party application problems
Also you said: it runs from cmd.
So run cmd.exe in ConEmu (as shell) and check!
The same issue when running cmd.exe in ConEmu.

But not using command prompt:

The only way for me to reproduce this issue is to run it in ConEmu with any shell (cmd or git bash).
I read trough the Third-party application problems page before submitting this issue, but seeing i can only reproduce it in ConEmu, i decided to report it here.
Just checked. And...

It is working with node 7.9.0. Regression in node?
ConEmu does not change environment variables while running applications.
It is working with node 7.9.0. Regression in node?
I think so yeah. I just tried it with node 7.9, works fine. Switching to node 8.0.0 seems to break it. I will open an issue at node.
I'll close this issue for now, hope we can find out whats happening at Node side. Thanks for your help @Maximus5
@Maximus5 it appears to be caused by an injected dll at ConEmu side: "ConEmuHq.dll"
https://github.com/nodejs/node/issues/14593#issuecomment-319676772
People are able to reproduce it in multiple node versions. Any ideas?
@Maximus5 IMHO the edge case here is that in node we can set an empty string env var:
process.env.foobar='';
attached is a minimally reproducing script and a Procmon PML trace
conemu-1209.zip
The env var foobar get converted from an empty string to a NULL with the first spawn
In the second spawn a bug on node's side converts the js undefined value to its string representation
@refack so this is an issue on node side only? Or on ConEmu side as well?
AFAICT on both sides
ComEmu converts empty strings to null
node convert null to undefined
ConEmu doesn't change environment. And hooked GetEnvironmentVariable properly returns empty string.
But Node checks for non-zero GetLastError() instead of described ERROR_ENVVAR_NOT_FOUND.
What does the ConEmuHq.dll do? Because it does change the behavior of node (regardless of the node bug)
It's all in docs: http://conemu.github.io/en/ConEmuHk.html
TL;DR - it's a required component to bypass conhost bugs and limitations.