Skip to content

Generated NODE_JS configuration breaks when EMSDK installation path contains spaces #1752

Description

@hd1534

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions