恢复固定 Node 在系统 PATH 的可见性
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Failing after 7m19s
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Failing after 7m49s
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Failing after 7m52s
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Failing after 8m9s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m7s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 2m50s
Project CI / Repository checks (pull_request) Successful in 3m48s
Project CI / Frontend tests (pull_request) Successful in 5m21s
Project CI / Backend tests (pull_request) Successful in 6m56s
Project CI / Native shell tests (pull_request) Successful in 7m55s
Project CI / AI game creator shell web tests (pull_request) Successful in 2m50s

- 上一版把固定 Node 只放在 /usr/local/lib/genarrative-node,未在 /usr/local/bin 建 node 链接
- command.exec 只信任 /usr/local/bin 等系统目录,导致 CI 上所有需要真实 node 的命令用例失败(找不到受信任的 node 可执行文件)
- 在 npm 固定版本步骤后恢复 /usr/local/bin/node 符号链接,并同步注释口径
This commit is contained in:
2026-09-21 03:06:32 +08:00
parent af4324a64d
commit dc54b1d048
+5 -3
View File
@@ -198,12 +198,14 @@ RUN test -n "${NPM_LOCK_SHA256}" \
# 依赖预热会在 workspace 内解析出 Node 发行包自带的 npm(例如 10.9.8),
# 并通过 PATH 里的 node_modules/.bin 影子化固定版本,因此全局固定版本在预热之后安装。
# 基础 runner 镜像把 /opt/acttoolcache/node/24.18.0/x64/bin 放在 PATH 最前,
# 会影子化固定 Node / npm。这里把固定工具链写成绝对路径 wrapper,
# 并用同一组 wrapper 覆盖 base 镜像残留的 toolcache bin避免 shell 是否登录改变解析结果。
# 基础 runner 镜像把 /opt/acttoolcache/node/24.18.0/x64/bin 放在 PATH 最前,会影子化固定 Node / npm
# 而 command.exec 只信任 /usr/local/bin 等系统目录,Node 必须在那里可见。
# 因此固定工具链写成绝对路径 wrapper,并用同一组链接覆盖 base 镜像残留的 toolcache bin
# 避免 shell 是否登录改变解析结果,同时保证 command.exec 能找到受信任 node。
RUN npm install --global --prefix /usr/local/lib/genarrative-node \
--no-audit --no-fund "npm@${NPM_VERSION}" \
&& test "$(/usr/local/lib/genarrative-node/bin/node /usr/local/lib/genarrative-node/lib/node_modules/npm/bin/npm-cli.js --version)" = "${NPM_VERSION}" \
&& ln -sfn /usr/local/lib/genarrative-node/bin/node /usr/local/bin/node \
&& rm -f /usr/local/bin/npm \
&& printf '%s\n' '#!/bin/sh' \
'exec /usr/local/lib/genarrative-node/bin/node /usr/local/lib/genarrative-node/lib/node_modules/npm/bin/npm-cli.js "$@"' \