Skip to content

Commit b0c7e62

Browse files
committed
[bootstrap] Honor EMSDK_NODE in bootstrap.py
When `EMSDK_NODE` is present in the environment, prepend its directory to `PATH` before running bootstrap actions. By default, emsdk avoids prepending its own node binary to `PATH` if a system node is already present in `PATH`. However, bootstrap actions (such as `npm ci`) may fail if the system node is an older incompatible version or lacks npm. See: emscripten-core#27614
1 parent 92a1d86 commit b0c7e62

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

bootstrap.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,19 @@ def run_cmd(cmd):
119119
]
120120

121121

122+
def enable_emsdk_node():
123+
# By default emsdk avoids prepending its node binary to PATH if another node
124+
# is already present. For running bootstrap actions (like `npm ci`), however,
125+
# we prefer the emsdk-provided node (and npm) because the system node might
126+
# be an incompatible version or lack npm.
127+
# Other emscripten tools can rely on the config file to find node so do not
128+
# need to do this.
129+
emsdk_node = os.environ.get('EMSDK_NODE')
130+
if emsdk_node:
131+
node_dir = os.path.dirname(emsdk_node)
132+
os.environ['PATH'] = node_dir + os.pathsep + os.environ['PATH']
133+
134+
122135
def main(args):
123136
parser = argparse.ArgumentParser(description=__doc__)
124137
parser.add_argument('-v', '--verbose', action='store_true', help='verbose', default=False)
@@ -130,6 +143,8 @@ def main(args):
130143
if args.install_git_hooks:
131144
return install_hooks()
132145

146+
enable_emsdk_node()
147+
133148
for name, deps, action in actions:
134149
if not args.force:
135150
if check_deps(name, deps):

0 commit comments

Comments
 (0)