Problem
When EMSDK is installed in a path containing spaces, em++ fails because the configured Node.js path is split into multiple arguments.
Steps to reproduce
git clone https://github.com/emscripten-core/emsdk.git "/private/tmp/emsdk with spaces"
cd "/private/tmp/emsdk with spaces"
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
em++ --version
Actual result
| Environment |
Value |
| OS |
macOS |
| Shell |
zsh |
| EMSDK |
latest |
| Bundled Node.js |
22.16.0 |
em++: warning: cannot check node version: [Errno 2] No such file or directory: '/private/tmp/emsdk' [-Wversion-check]
shared:INFO: (Emscripten: Running sanity checks)
em++: error: the configured node executable (['/private/tmp/emsdk', 'with', 'spaces/node/22.16.0_64bit/bin/node']) does not seem to work, check the paths in /private/tmp/emsdk with spaces/.emscripten ([Errno 2] No such file or directory: '/private/tmp/emsdk')
Suspected cause
The generated .emscripten file contains:
NODE_JS = '$CFGDIR/node/22.16.0_64bit/bin/node'
The configuration originates from the Node tool entries in
emsdk_manifest.json:
"activated_cfg": "NODE_JS='%installation_dir%/bin/node%.exe%'"
After $CFGDIR is expanded, NODE_JS is normalized through listify() in
tools/config.py.
Because listify() uses shell-like parsing, the resulting Node.js path is split at spaces instead of being preserved as a single executable argument.
Preserving double quotes inside the generated NODE_JS value appears to prevent this split:
NODE_JS = '"$CFGDIR/node/22.16.0_64bit/bin/node"'
One possible change would be to preserve embedded double quotes in the Node tool configuration in emsdk_manifest.json:
- "activated_cfg": "NODE_JS='%installation_dir%/bin/node%.exe%'"
+ "activated_cfg": "NODE_JS='\"%installation_dir%/bin/node%.exe%\"'"
After emsdk activate, this should generate an equivalent .emscripten value containing inner double quotes:
NODE_JS = '"$CFGDIR/node/22.16.0_64bit/bin/node"'
The same activated_cfg template is used by multiple Node tool entries in the manifest, so the change may need to be applied to all relevant entries. Alternatively, the quoting could be handled centrally by the .emscripten generation logic in generate_em_config().
This is only a suggested direction; the effect on other platforms and NODE_JS consumers would need to be verified.
Expected result
em++ --version should successfully execute the bundled Node.js binary when EMSDK is installed in a path containing spaces.
Workaround
Installing EMSDK in a path without spaces avoids the issue.
Problem
When EMSDK is installed in a path containing spaces,
em++fails because the configured Node.js path is split into multiple arguments.Steps to reproduce
Actual result
Suspected cause
The generated
.emscriptenfile contains:The configuration originates from the Node tool entries in
emsdk_manifest.json:After
$CFGDIRis expanded,NODE_JSis normalized throughlistify()intools/config.py.Because
listify()uses shell-like parsing, the resulting Node.js path is split at spaces instead of being preserved as a single executable argument.Preserving double quotes inside the generated
NODE_JSvalue appears to prevent this split:One possible change would be to preserve embedded double quotes in the Node tool configuration in
emsdk_manifest.json:After
emsdk activate, this should generate an equivalent.emscriptenvalue containing inner double quotes:The same
activated_cfgtemplate is used by multiple Node tool entries in the manifest, so the change may need to be applied to all relevant entries. Alternatively, the quoting could be handled centrally by the.emscriptengeneration logic ingenerate_em_config().This is only a suggested direction; the effect on other platforms and
NODE_JSconsumers would need to be verified.Expected result
em++ --versionshould successfully execute the bundled Node.js binary when EMSDK is installed in a path containing spaces.Workaround
Installing EMSDK in a path without spaces avoids the issue.