From e60a1606636c4735c7cb02e12a609ce72e20e372 Mon Sep 17 00:00:00 2001 From: croquete1 Date: Thu, 12 Nov 2026 08:25:21 +0000 Subject: [PATCH 01/21] feat(pipe): environment preflight before setup Fail fast with an actionable message when the build container is missing git/node or ships a Node major that the repository's .nvmrc rejects. Without this, a version mismatch surfaces as a cryptic mid-setup crash (e.g. "libuv crash. Detected 20.19.2" from a repo's check-node-version script) that is hard to trace back to the build image. The preflight runs right after checkout (so .nvmrc is present) and before the setup command, turning the failure into: "node incompatible: repo requires Node 24.x but build environment has Node 20.x; rebuild the build image". Zero behaviour change on correctly provisioned environments: it emits a single "preflight ok" line and proceeds. Co-Authored-By: Claude Opus 4.8 --- src/pipe.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pipe.rs b/src/pipe.rs index ac577966..e33ac9ef 100644 --- a/src/pipe.rs +++ b/src/pipe.rs @@ -260,6 +260,15 @@ async fn prep(a: &Ax, j: &mut Job) -> R<()> { ok(a, j, &format!("git checkout -q -B {} refs/ao/head", q(&br)), 1800).await?; j.d["old"] = json!(ok(a, j, "git rev-parse HEAD", 60).await?); } + // Environment preflight: fail fast with an actionable message when the build + // container lacks git/node or ships a Node major that the repo's .nvmrc rejects. + // This turns a cryptic mid-setup crash (e.g. "libuv crash. Detected 20.19.2") + // into a clear instruction to rebuild the build image. + let preflight = r#"command -v git >/dev/null || { echo "git missing in build environment"; exit 1; }; command -v node >/dev/null || { echo "node missing in build environment"; exit 1; }; have=$(node -v | tr -d v); hmaj=${have%%.*}; want=; if [ -f .nvmrc ]; then want=$(tr -dc 0-9. < .nvmrc); fi; wmaj=${want%%.*}; if [ -n "$wmaj" ] && [ "$wmaj" != "$hmaj" ]; then echo "node incompatible: repo requires Node $want but build environment has Node $have; rebuild the build image"; exit 1; fi; echo "preflight ok: node $have (wants ${want:-no requirement})""#; + let pf = x(a, j, &format!("bash -c {} 2>&1", q(preflight)), 120).await; + if pf.c != 0 { + return drop(format!("environment preflight failed (exit {}): {}", pf.c, crate::sh::last(pf.o.trim(), 300))); + } let su = rp(a, &j.repo)["setup"].as_str().unwrap_or("").trim().to_string(); if !su.is_empty() { a.say("repro", &format!("[{}] setup: {}", j.h(), crate::sh::head(&su, 80)), Some(j.id)); From 0eb5454838d54b74c428a6a813576b78d9da4a76 Mon Sep 17 00:00:00 2001 From: croquete1 Date: Thu, 12 Nov 2026 08:59:35 +0000 Subject: [PATCH 02/21] fix(pipe): harden preflight per review (gate Node on .nvmrc, robust parsing) Address CodeRabbit review: - git stays unconditional; all Node checks now run only when .nvmrc exists, so repos without a Node requirement no longer fail on Node-less machines. - .nvmrc parsing strips comments and a leading "v", takes the first line; aliases (lts/*) or non-plain versions are reported and skipped instead of silently passing. - capture and check `node -v`: a broken Node install fails with its own diagnostic rather than passing the compatibility check. Co-Authored-By: Claude Opus 4.8 --- src/pipe.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/pipe.rs b/src/pipe.rs index e33ac9ef..cfde45d9 100644 --- a/src/pipe.rs +++ b/src/pipe.rs @@ -263,8 +263,26 @@ async fn prep(a: &Ax, j: &mut Job) -> R<()> { // Environment preflight: fail fast with an actionable message when the build // container lacks git/node or ships a Node major that the repo's .nvmrc rejects. // This turns a cryptic mid-setup crash (e.g. "libuv crash. Detected 20.19.2") - // into a clear instruction to rebuild the build image. - let preflight = r#"command -v git >/dev/null || { echo "git missing in build environment"; exit 1; }; command -v node >/dev/null || { echo "node missing in build environment"; exit 1; }; have=$(node -v | tr -d v); hmaj=${have%%.*}; want=; if [ -f .nvmrc ]; then want=$(tr -dc 0-9. < .nvmrc); fi; wmaj=${want%%.*}; if [ -n "$wmaj" ] && [ "$wmaj" != "$hmaj" ]; then echo "node incompatible: repo requires Node $want but build environment has Node $have; rebuild the build image"; exit 1; fi; echo "preflight ok: node $have (wants ${want:-no requirement})""#; + // into a clear instruction to rebuild the build image. git is always required; + // Node checks only apply when the repo pins a plain version via .nvmrc (aliases + // like lts/* or a broken Node install are reported rather than silently passed). + let preflight = r#"command -v git >/dev/null || { echo "git missing in build environment"; exit 1; } +if [ -f .nvmrc ]; then + want=$(sed 's/#.*//' .nvmrc | head -n1 | tr -d ' \t\r' | sed 's/^v//') + case "$want" in + ''|*[!0-9.]*) + echo "preflight: .nvmrc requirement '$want' is not a plain version (alias/empty); skipping Node major check" ;; + *) + wmaj=${want%%.*} + command -v node >/dev/null || { echo "node missing but .nvmrc requires Node $want; rebuild the build image"; exit 1; } + have=$(node -v 2>&1) || { echo "node failed to run: $have"; exit 1; } + have=${have#v}; hmaj=${have%%.*} + if [ "$wmaj" != "$hmaj" ]; then echo "node incompatible: repo requires Node $want but build environment has Node $have; rebuild the build image"; exit 1; fi + echo "preflight ok: node $have (wants $want)" ;; + esac +else + echo "preflight ok: git present, no .nvmrc requirement" +fi"#; let pf = x(a, j, &format!("bash -c {} 2>&1", q(preflight)), 120).await; if pf.c != 0 { return drop(format!("environment preflight failed (exit {}): {}", pf.c, crate::sh::last(pf.o.trim(), 300))); From 5a2f37df06e2960f6f422c685bb8bf8cd8c3f7cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Thu, 12 Nov 2026 13:10:50 +0000 Subject: [PATCH 03/21] fix(pipe): resolve .nvmrc aliases and enforce preflight --- src/pipe.rs | 113 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 94 insertions(+), 19 deletions(-) diff --git a/src/pipe.rs b/src/pipe.rs index cfde45d9..8fc6ba3e 100644 --- a/src/pipe.rs +++ b/src/pipe.rs @@ -10,6 +10,35 @@ use std::collections::BTreeSet; pub const RND: u64 = 2; const CIT: u64 = 150 * 60; +const ENV_PREFLIGHT: &str = r#"command -v git >/dev/null 2>&1 || { echo "git missing in build environment"; exit 1; } +if [ -f .nvmrc ]; then + want=$(sed 's/#.*//' .nvmrc | head -n1 | tr -d ' \t\r') + if [ -z "$want" ]; then echo "unsupported empty .nvmrc requirement"; exit 1; fi + command -v node >/dev/null 2>&1 || { echo "node missing but .nvmrc requires Node $want; rebuild the build image"; exit 1; } + have=$(node -v 2>&1) || { echo "node failed to run: $have"; exit 1; } + case "$have" in v[0-9]*) ;; *) echo "node returned an invalid version: $have"; exit 1 ;; esac + have=${have#v} + case "$have" in *[!0-9.]*|'') echo "node returned an invalid version: $have"; exit 1 ;; esac + case "$want" in v*) want=${want#v} ;; esac + case "$want" in + *[!0-9.]* ) + nvm_file="${NVM_DIR:-$HOME/.nvm}/nvm.sh" + if [ -s "$nvm_file" ]; then . "$nvm_file"; fi + command -v nvm >/dev/null 2>&1 || { echo "unsupported .nvmrc requirement '$want': install nvm to resolve this alias"; exit 1; } + resolved=$(nvm version "$want" 2>&1) || { echo "unsupported .nvmrc requirement '$want': $resolved"; exit 1; } + case "$resolved" in v[0-9]*) ;; *) echo "unsupported .nvmrc requirement '$want': nvm could not resolve it"; exit 1 ;; esac + resolved=${resolved#v} + case "$resolved" in *[!0-9.]*|'') echo "unsupported .nvmrc requirement '$want': nvm returned an invalid version"; exit 1 ;; esac + wmaj=${resolved%%.*} ;; + *) wmaj=${want%%.*} ;; + esac + case "$wmaj" in ''|*[!0-9]*) echo "unsupported .nvmrc requirement '$want': no Node major version"; exit 1 ;; esac + hmaj=${have%%.*} + if [ "$wmaj" != "$hmaj" ]; then echo "node incompatible: repo requires Node $want but build environment has Node $have; rebuild the build image"; exit 1; fi + echo "preflight ok: node $have (wants $want)" +else + echo "preflight ok: git present, no .nvmrc requirement" +fi"#; pub fn gitb() -> String { std::env::var("APOLLO_OFFICE_REMOTE").unwrap_or_else(|_| "https://github.com/".into()) @@ -266,26 +295,9 @@ async fn prep(a: &Ax, j: &mut Job) -> R<()> { // into a clear instruction to rebuild the build image. git is always required; // Node checks only apply when the repo pins a plain version via .nvmrc (aliases // like lts/* or a broken Node install are reported rather than silently passed). - let preflight = r#"command -v git >/dev/null || { echo "git missing in build environment"; exit 1; } -if [ -f .nvmrc ]; then - want=$(sed 's/#.*//' .nvmrc | head -n1 | tr -d ' \t\r' | sed 's/^v//') - case "$want" in - ''|*[!0-9.]*) - echo "preflight: .nvmrc requirement '$want' is not a plain version (alias/empty); skipping Node major check" ;; - *) - wmaj=${want%%.*} - command -v node >/dev/null || { echo "node missing but .nvmrc requires Node $want; rebuild the build image"; exit 1; } - have=$(node -v 2>&1) || { echo "node failed to run: $have"; exit 1; } - have=${have#v}; hmaj=${have%%.*} - if [ "$wmaj" != "$hmaj" ]; then echo "node incompatible: repo requires Node $want but build environment has Node $have; rebuild the build image"; exit 1; fi - echo "preflight ok: node $have (wants $want)" ;; - esac -else - echo "preflight ok: git present, no .nvmrc requirement" -fi"#; - let pf = x(a, j, &format!("bash -c {} 2>&1", q(preflight)), 120).await; + let pf = x(a, j, &format!("bash -c {} 2>&1", q(ENV_PREFLIGHT)), 120).await; if pf.c != 0 { - return drop(format!("environment preflight failed (exit {}): {}", pf.c, crate::sh::last(pf.o.trim(), 300))); + return Err(oe(&pf, "environment preflight", &j.h())); } let su = rp(a, &j.repo)["setup"].as_str().unwrap_or("").trim().to_string(); if !su.is_empty() { @@ -1893,6 +1905,69 @@ pub async fn guard(a: Ax) { mod t { use super::*; + #[cfg(unix)] + fn run_preflight(nvmrc: Option<&str>, node_body: &str, nvm_resolved: &str) -> std::process::Output { + use std::os::unix::fs::PermissionsExt; + + let root = std::env::temp_dir().join(format!( + "apollo-preflight-{}-{}", + std::process::id(), + hex::encode(rand::random::<[u8; 8]>()) + )); + let bin = root.join("bin"); + let nvm_dir = root.join("nvm"); + std::fs::create_dir_all(&bin).unwrap(); + std::fs::create_dir_all(&nvm_dir).unwrap(); + if let Some(requirement) = nvmrc { + std::fs::write(root.join(".nvmrc"), requirement).unwrap(); + } + for (name, body) in [ + ("git", "exit 0"), + ("node", node_body), + ("nvm", "printf '%s\\n' \"$NVM_RESOLVED\""), + ] { + let path = bin.join(name); + std::fs::write(&path, format!("#!/bin/sh\n{body}\n")).unwrap(); + let mut permissions = std::fs::metadata(&path).unwrap().permissions(); + permissions.set_mode(0o700); + std::fs::set_permissions(path, permissions).unwrap(); + } + let output = std::process::Command::new("/bin/bash") + .arg("-c") + .arg(ENV_PREFLIGHT) + .current_dir(&root) + .env("PATH", format!("{}:/usr/bin:/bin", bin.display())) + .env("NVM_DIR", &nvm_dir) + .env("NVM_RESOLVED", nvm_resolved) + .output() + .unwrap(); + let _ = std::fs::remove_dir_all(root); + output + } + + #[cfg(unix)] + #[test] + fn environment_preflight_checks_pinned_node_versions_and_aliases() { + let no_nvmrc = run_preflight(None, "echo broken-node >&2; exit 9", ""); + assert!(no_nvmrc.status.success()); + + let pinned = run_preflight( + Some("v20.1.0 # keep the major stable\n"), + "printf 'v20.19.0\n'", + "", + ); + assert!(pinned.status.success(), "{}", String::from_utf8_lossy(&pinned.stderr)); + + let alias = run_preflight(Some("lts/argon\n"), "printf 'v20.19.0\n'", "v20.20.0"); + assert!(alias.status.success(), "{}", String::from_utf8_lossy(&alias.stderr)); + + let mismatch = run_preflight(Some("18\n"), "printf 'v20.19.0\n'", ""); + assert!(!mismatch.status.success()); + + let unresolved = run_preflight(Some("lts/unknown\n"), "printf 'v20.19.0\n'", "N/A"); + assert!(!unresolved.status.success()); + } + #[cfg(unix)] #[tokio::test] async fn cancelled_ci_releases_build_capacity() { From e3b9bd5dfffe6d6fd9ce30f511e8c45a765c380c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Thu, 12 Nov 2026 13:12:47 +0000 Subject: [PATCH 04/21] fix(pipe): route preflight failures through drop --- src/pipe.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pipe.rs b/src/pipe.rs index 8fc6ba3e..1b7ac6ee 100644 --- a/src/pipe.rs +++ b/src/pipe.rs @@ -297,7 +297,19 @@ async fn prep(a: &Ax, j: &mut Job) -> R<()> { // like lts/* or a broken Node install are reported rather than silently passed). let pf = x(a, j, &format!("bash -c {} 2>&1", q(ENV_PREFLIGHT)), 120).await; if pf.c != 0 { - return Err(oe(&pf, "environment preflight", &j.h())); + let diagnostic = crate::sh::last( + if pf.e.trim().is_empty() { + pf.o.trim() + } else { + pf.e.trim() + }, + 300, + ); + let message = format!("environment preflight failed (exit {}): {diagnostic}", pf.c); + if crate::app::hostish(&message) || crate::app::netish(&message) { + return Err(oe(&pf, "environment preflight", &j.h())); + } + return drop(message); } let su = rp(a, &j.repo)["setup"].as_str().unwrap_or("").trim().to_string(); if !su.is_empty() { From 374656ec78f96f648e30831ae776345c3437c914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Sun, 15 Nov 2026 20:40:02 +0000 Subject: [PATCH 05/21] fix(build): ship Node 24 LTS and fnm in worker image --- src/sh.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/sh.rs b/src/sh.rs index 5b2dc4db..a7d02d25 100644 --- a/src/sh.rs +++ b/src/sh.rs @@ -341,7 +341,7 @@ pub fn hbid(a: &App, h: &str) -> String { ho(a, h).map(|x| hb(a, &x)).unwrap_or_else(|| "/work".into()) } -pub const PRE: &str = "ulimit -n 10240 2>/dev/null; export PATH=\"$HOME/.cargo/bin:$HOME/.local/bin:$HOME/go/bin:/usr/local/go/bin:/opt/homebrew/bin:/usr/local/bin:$PATH\" CARGO_TERM_COLOR=never NO_COLOR=1 CI=1 GIT_TERMINAL_PROMPT=0 CARGO_PROFILE_DEV_DEBUG=line-tables-only CARGO_PROFILE_TEST_DEBUG=line-tables-only CARGO_PROFILE_RELEASE_LTO=off CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16 CARGO_PROFILE_BENCH_LTO=off; to() { s=$1; shift; if command -v timeout >/dev/null 2>&1 && timeout --version 2>/dev/null | head -n 1 | grep -q 'coreutils'; then timeout -k 10 \"$s\" \"$@\"; else \"$@\"; fi; }\n"; +pub const PRE: &str = "ulimit -n 10240 2>/dev/null; export PATH=\"$HOME/.cargo/bin:$HOME/.local/bin:$HOME/go/bin:/usr/local/go/bin:/opt/homebrew/bin:/usr/local/bin:$PATH\" CARGO_TERM_COLOR=never NO_COLOR=1 CI=1 GIT_TERMINAL_PROMPT=0 CARGO_PROFILE_DEV_DEBUG=line-tables-only CARGO_PROFILE_TEST_DEBUG=line-tables-only CARGO_PROFILE_RELEASE_LTO=off CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16 CARGO_PROFILE_BENCH_LTO=off; to() { s=$1; shift; if command -v timeout >/dev/null 2>&1 && timeout --version 2>/dev/null | head -n 1 | grep -q 'coreutils'; then timeout -k 10 \"$s\" \"$@\"; else \"$@\"; fi; }\nif [ \"${APOLLO_OFFICE_FNM:-}\" = 1 ] && command -v fnm >/dev/null 2>&1; then eval \"$(fnm env --shell bash --use-on-cd --resolve-engines --version-file-strategy recursive)\"; fi\n"; fn sshv(h: &Ho) -> Vec { let mut v: Vec = vec!["-o".into(), "ConnectTimeout=15".into(), "-o".into(), "ServerAliveInterval=15".into(), "-o".into(), "ServerAliveCountMax=4".into(), "-o".into(), "BatchMode=yes".into()]; @@ -411,15 +411,27 @@ pub async fn hx(a: &App, id: &str, s: &str, t: u64) -> Out { hxl(a, id, s, t, None).await } -pub const DF: &str = r#"FROM rust:1-trixie +pub const DF: &str = r#"FROM node:24-trixie-slim AS node24 +FROM rust:1-trixie RUN apt-get update && apt-get install -y --no-install-recommends \ pkg-config libssl-dev clang cmake git curl ca-certificates procps xz-utils unzip libxdo-dev mesa-vulkan-drivers \ - python3 python3-pip python3-venv python3-dev nodejs npm golang-go \ + python3 python3-pip python3-venv python3-dev golang-go \ libasound2-dev libfontconfig1-dev libfreetype-dev libgl1-mesa-dev libgtk-3-dev libwayland-dev \ libx11-dev libxcursor-dev libxi-dev libxkbcommon-dev libxrandr-dev libudev-dev xvfb \ && rm -rf /var/lib/apt/lists/* +# Use the official Node 24 LTS distribution rather than Debian's older nodejs. +COPY --from=node24 /usr/local/bin/node /usr/local/bin/node +COPY --from=node24 /usr/local/lib/node_modules /usr/local/lib/node_modules +COPY --from=node24 /usr/local/include/node /usr/local/include/node +RUN ln -sf ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ + && ln -sf ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \ + && curl -fsSL https://fnm.vercel.app/install -o /tmp/install-fnm.sh \ + && bash /tmp/install-fnm.sh --install-dir /usr/local/bin --skip-shell \ + && rm -f /tmp/install-fnm.sh \ + && node --version | grep -Eq '^v24\\.' \ + && npm --version >/dev/null && fnm --version >/dev/null RUN rustup component add rustfmt clippy && rustup target add wasm32-unknown-unknown && npm install -g pnpm yarn && pip3 install --break-system-packages pytest -ENV CARGO_TERM_COLOR=never CARGO_INCREMENTAL=0 PIP_BREAK_SYSTEM_PACKAGES=1 +ENV CARGO_TERM_COLOR=never CARGO_INCREMENTAL=0 PIP_BREAK_SYSTEM_PACKAGES=1 APOLLO_OFFICE_FNM=1 FNM_DIR=/opt/apollo-fnm WORKDIR /work "#; From 30952df11c3694437c31cab793e381eff6361a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Sun, 15 Nov 2026 20:42:11 +0000 Subject: [PATCH 06/21] fix(pipe): provision Node non-blockingly and diagnose setup failures --- src/pipe.rs | 181 ++++++++++++++++++++++++++++------------------------ 1 file changed, 96 insertions(+), 85 deletions(-) diff --git a/src/pipe.rs b/src/pipe.rs index 1b7ac6ee..a7b546c3 100644 --- a/src/pipe.rs +++ b/src/pipe.rs @@ -10,34 +10,25 @@ use std::collections::BTreeSet; pub const RND: u64 = 2; const CIT: u64 = 150 * 60; -const ENV_PREFLIGHT: &str = r#"command -v git >/dev/null 2>&1 || { echo "git missing in build environment"; exit 1; } +const NODE_VERSION_SELECTION: &str = r#"if [ "${APOLLO_OFFICE_FNM:-}" != 1 ] || ! command -v fnm >/dev/null 2>&1; then exit 0; fi +if [ -f .nvmrc ] || [ -f .node-version ] || { [ -f package.json ] && python3 -c 'import json,sys; e=json.load(open("package.json", encoding="utf-8")).get("engines", {}); sys.exit(0 if isinstance(e, dict) and isinstance(e.get("node"), str) and e["node"].strip() else 1)' >/dev/null 2>&1; }; then + fnm use --install-if-missing --resolve-engines +fi"#; +const NODE_VERSION_DIAGNOSTIC: &str = r#"source= +required= if [ -f .nvmrc ]; then - want=$(sed 's/#.*//' .nvmrc | head -n1 | tr -d ' \t\r') - if [ -z "$want" ]; then echo "unsupported empty .nvmrc requirement"; exit 1; fi - command -v node >/dev/null 2>&1 || { echo "node missing but .nvmrc requires Node $want; rebuild the build image"; exit 1; } - have=$(node -v 2>&1) || { echo "node failed to run: $have"; exit 1; } - case "$have" in v[0-9]*) ;; *) echo "node returned an invalid version: $have"; exit 1 ;; esac - have=${have#v} - case "$have" in *[!0-9.]*|'') echo "node returned an invalid version: $have"; exit 1 ;; esac - case "$want" in v*) want=${want#v} ;; esac - case "$want" in - *[!0-9.]* ) - nvm_file="${NVM_DIR:-$HOME/.nvm}/nvm.sh" - if [ -s "$nvm_file" ]; then . "$nvm_file"; fi - command -v nvm >/dev/null 2>&1 || { echo "unsupported .nvmrc requirement '$want': install nvm to resolve this alias"; exit 1; } - resolved=$(nvm version "$want" 2>&1) || { echo "unsupported .nvmrc requirement '$want': $resolved"; exit 1; } - case "$resolved" in v[0-9]*) ;; *) echo "unsupported .nvmrc requirement '$want': nvm could not resolve it"; exit 1 ;; esac - resolved=${resolved#v} - case "$resolved" in *[!0-9.]*|'') echo "unsupported .nvmrc requirement '$want': nvm returned an invalid version"; exit 1 ;; esac - wmaj=${resolved%%.*} ;; - *) wmaj=${want%%.*} ;; - esac - case "$wmaj" in ''|*[!0-9]*) echo "unsupported .nvmrc requirement '$want': no Node major version"; exit 1 ;; esac - hmaj=${have%%.*} - if [ "$wmaj" != "$hmaj" ]; then echo "node incompatible: repo requires Node $want but build environment has Node $have; rebuild the build image"; exit 1; fi - echo "preflight ok: node $have (wants $want)" -else - echo "preflight ok: git present, no .nvmrc requirement" + source=.nvmrc + required=$(sed 's/#.*//' .nvmrc | sed -n '/[^[:space:]]/{s/^[[:space:]]*//;s/[[:space:]]*$//;p;q;}') +elif [ -f .node-version ]; then + source=.node-version + required=$(sed 's/#.*//' .node-version | sed -n '/[^[:space:]]/{s/^[[:space:]]*//;s/[[:space:]]*$//;p;q;}') +elif [ -f package.json ] && command -v python3 >/dev/null 2>&1; then + source=package.json + required=$(python3 -c 'import json; e=json.load(open("package.json", encoding="utf-8")).get("engines", {}); print(e.get("node", "") if isinstance(e, dict) else "")' 2>/dev/null) || required= +fi +if [ -n "$required" ]; then + have=$(node --version 2>/dev/null) || have=unavailable + printf 'Node hint: %s requests %s; the environment reports %s. Check version selection and setup tooling.\n' "$source" "$required" "$have" fi"#; pub fn gitb() -> String { @@ -289,34 +280,34 @@ async fn prep(a: &Ax, j: &mut Job) -> R<()> { ok(a, j, &format!("git checkout -q -B {} refs/ao/head", q(&br)), 1800).await?; j.d["old"] = json!(ok(a, j, "git rev-parse HEAD", 60).await?); } - // Environment preflight: fail fast with an actionable message when the build - // container lacks git/node or ships a Node major that the repo's .nvmrc rejects. - // This turns a cryptic mid-setup crash (e.g. "libuv crash. Detected 20.19.2") - // into a clear instruction to rebuild the build image. git is always required; - // Node checks only apply when the repo pins a plain version via .nvmrc (aliases - // like lts/* or a broken Node install are reported rather than silently passed). - let pf = x(a, j, &format!("bash -c {} 2>&1", q(ENV_PREFLIGHT)), 120).await; - if pf.c != 0 { - let diagnostic = crate::sh::last( - if pf.e.trim().is_empty() { - pf.o.trim() - } else { - pf.e.trim() - }, - 300, + // Best-effort Node provisioning only in the managed build image. Do not + // reject a repository here: its setup may install or select Node itself. + let node_selection = x(a, j, &format!("bash -c {} 2>&1", q(NODE_VERSION_SELECTION)), 360).await; + if node_selection.c != 0 { + a.say( + "repro", + &format!( + "[{}] optional Node selection failed (setup will continue): {}", + j.h(), + crate::sh::last(node_selection.all().trim(), 240) + ), + Some(j.id), ); - let message = format!("environment preflight failed (exit {}): {diagnostic}", pf.c); - if crate::app::hostish(&message) || crate::app::netish(&message) { - return Err(oe(&pf, "environment preflight", &j.h())); - } - return drop(message); } let su = rp(a, &j.repo)["setup"].as_str().unwrap_or("").trim().to_string(); if !su.is_empty() { a.say("repro", &format!("[{}] setup: {}", j.h(), crate::sh::head(&su, 80)), Some(j.id)); let r = x(a, j, &format!("to 1800 bash -c {} 2>&1 | tail -c 3000; exit ${{PIPESTATUS[0]}}", q(&su)), 1900).await; if r.c != 0 { - return drop(format!("setup command failed (exit {}): {}", r.c, crate::sh::last(r.o.trim(), 300))); + let mut reason = format!("setup command failed (exit {}): {}", r.c, crate::sh::last(r.o.trim(), 300)); + // Diagnostic only: the original setup error remains authoritative. + // In particular, a repository may install Node through its own setup. + let hint = x(a, j, &format!("bash -c {} 2>&1", q(NODE_VERSION_DIAGNOSTIC)), 60).await; + if hint.c == 0 && !hint.o.trim().is_empty() { + reason.push('\n'); + reason.push_str(&crate::sh::last(hint.o.trim(), 500)); + } + return drop(reason); } ok(a, j, "git checkout -q -- . 2>/dev/null; true", 60).await?; } @@ -1918,39 +1909,32 @@ mod t { use super::*; #[cfg(unix)] - fn run_preflight(nvmrc: Option<&str>, node_body: &str, nvm_resolved: &str) -> std::process::Output { + fn run_node_script(script: &str, nvmrc: Option<&str>, node_version: Option<&str>, package: Option<&str>, enable_fnm: bool) -> std::process::Output { use std::os::unix::fs::PermissionsExt; let root = std::env::temp_dir().join(format!( - "apollo-preflight-{}-{}", + "apollo-node-env-{}-{}", std::process::id(), hex::encode(rand::random::<[u8; 8]>()) )); let bin = root.join("bin"); - let nvm_dir = root.join("nvm"); std::fs::create_dir_all(&bin).unwrap(); - std::fs::create_dir_all(&nvm_dir).unwrap(); - if let Some(requirement) = nvmrc { - std::fs::write(root.join(".nvmrc"), requirement).unwrap(); - } - for (name, body) in [ - ("git", "exit 0"), - ("node", node_body), - ("nvm", "printf '%s\\n' \"$NVM_RESOLVED\""), - ] { - let path = bin.join(name); - std::fs::write(&path, format!("#!/bin/sh\n{body}\n")).unwrap(); - let mut permissions = std::fs::metadata(&path).unwrap().permissions(); - permissions.set_mode(0o700); - std::fs::set_permissions(path, permissions).unwrap(); + for (file, body) in [(".nvmrc", nvmrc), (".node-version", node_version), ("package.json", package)] { + if let Some(body) = body { + std::fs::write(root.join(file), body).unwrap(); + } } + let fnm = bin.join("fnm"); + std::fs::write(&fnm, "#!/bin/sh\nprintf 'fnm-called: %s\\n' \"$*\"\n").unwrap(); + let mut permissions = std::fs::metadata(&fnm).unwrap().permissions(); + permissions.set_mode(0o700); + std::fs::set_permissions(&fnm, permissions).unwrap(); let output = std::process::Command::new("/bin/bash") .arg("-c") - .arg(ENV_PREFLIGHT) + .arg(script) .current_dir(&root) - .env("PATH", format!("{}:/usr/bin:/bin", bin.display())) - .env("NVM_DIR", &nvm_dir) - .env("NVM_RESOLVED", nvm_resolved) + .env("PATH", format!("{}:{}", bin.display(), std::env::var("PATH").unwrap_or_default())) + .env("APOLLO_OFFICE_FNM", if enable_fnm { "1" } else { "0" }) .output() .unwrap(); let _ = std::fs::remove_dir_all(root); @@ -1959,25 +1943,52 @@ mod t { #[cfg(unix)] #[test] - fn environment_preflight_checks_pinned_node_versions_and_aliases() { - let no_nvmrc = run_preflight(None, "echo broken-node >&2; exit 9", ""); - assert!(no_nvmrc.status.success()); - - let pinned = run_preflight( - Some("v20.1.0 # keep the major stable\n"), - "printf 'v20.19.0\n'", - "", - ); - assert!(pinned.status.success(), "{}", String::from_utf8_lossy(&pinned.stderr)); + fn node_selection_is_optional_and_supports_version_sources() { + let none = run_node_script(NODE_VERSION_SELECTION, None, None, None, true); + assert!(none.status.success()); + assert!(none.stdout.is_empty()); + + let pinned = run_node_script(NODE_VERSION_SELECTION, Some("v24.1.0\n"), None, None, true); + assert!(pinned.status.success()); + assert!(String::from_utf8_lossy(&pinned.stdout).contains("fnm-called: use --install-if-missing --resolve-engines")); + + let node_version = run_node_script(NODE_VERSION_SELECTION, None, Some("22\n"), None, true); + assert!(node_version.status.success()); + assert!(String::from_utf8_lossy(&node_version.stdout).contains("fnm-called: use")); + + let engine = run_node_script(NODE_VERSION_SELECTION, None, None, Some(r#"{"engines":{"node":">=22 <25"}}"#), true); + assert!(engine.status.success()); + assert!(String::from_utf8_lossy(&engine.stdout).contains("fnm-called: use")); + + let no_engine = run_node_script(NODE_VERSION_SELECTION, None, None, Some(r#"{"name":"no-node-requirement"}"#), true); + assert!(no_engine.status.success()); + assert!(no_engine.stdout.is_empty()); + + let host = run_node_script(NODE_VERSION_SELECTION, Some("24\n"), None, None, false); + assert!(host.status.success()); + assert!(host.stdout.is_empty()); + } + + #[cfg(unix)] + #[test] + fn node_diagnostic_only_reports_existing_requirements() { + let none = run_node_script(NODE_VERSION_DIAGNOSTIC, None, None, None, false); + assert!(none.status.success()); + assert!(none.stdout.is_empty()); + + let pinned = run_node_script(NODE_VERSION_DIAGNOSTIC, Some("24 # pinned major\n"), None, None, false); + let message = String::from_utf8_lossy(&pinned.stdout); + assert!(pinned.status.success()); + assert!(message.contains(".nvmrc requests 24;"), "{message}"); - let alias = run_preflight(Some("lts/argon\n"), "printf 'v20.19.0\n'", "v20.20.0"); - assert!(alias.status.success(), "{}", String::from_utf8_lossy(&alias.stderr)); + let node_version = run_node_script(NODE_VERSION_DIAGNOSTIC, None, Some("22\n"), None, false); + assert!(String::from_utf8_lossy(&node_version.stdout).contains(".node-version requests 22;")); - let mismatch = run_preflight(Some("18\n"), "printf 'v20.19.0\n'", ""); - assert!(!mismatch.status.success()); + let engine = run_node_script(NODE_VERSION_DIAGNOSTIC, None, None, Some(r#"{"engines":{"node":">=20 <25"}}"#), false); + assert!(String::from_utf8_lossy(&engine.stdout).contains("package.json requests >=20 <25;")); - let unresolved = run_preflight(Some("lts/unknown\n"), "printf 'v20.19.0\n'", "N/A"); - assert!(!unresolved.status.success()); + let ignored = run_node_script(NODE_VERSION_DIAGNOSTIC, None, None, Some(r#"{"name":"no-engines"}"#), false); + assert!(ignored.stdout.is_empty()); } #[cfg(unix)] From c5627c196c9c636e9dbe07e1df982d89c243be23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Sun, 15 Nov 2026 20:42:28 +0000 Subject: [PATCH 07/21] fix(build): correct Node 24 image version smoke check --- src/sh.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sh.rs b/src/sh.rs index a7d02d25..3b857e45 100644 --- a/src/sh.rs +++ b/src/sh.rs @@ -428,7 +428,7 @@ RUN ln -sf ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ && curl -fsSL https://fnm.vercel.app/install -o /tmp/install-fnm.sh \ && bash /tmp/install-fnm.sh --install-dir /usr/local/bin --skip-shell \ && rm -f /tmp/install-fnm.sh \ - && node --version | grep -Eq '^v24\\.' \ + && node --version | grep -Eq '^v24\.' \ && npm --version >/dev/null && fnm --version >/dev/null RUN rustup component add rustfmt clippy && rustup target add wasm32-unknown-unknown && npm install -g pnpm yarn && pip3 install --break-system-packages pytest ENV CARGO_TERM_COLOR=never CARGO_INCREMENTAL=0 PIP_BREAK_SYSTEM_PACKAGES=1 APOLLO_OFFICE_FNM=1 FNM_DIR=/opt/apollo-fnm From a48a8eb569978f028c628af216d101f8ed8dc66e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Sun, 15 Nov 2026 20:45:51 +0000 Subject: [PATCH 08/21] fix(worker): preserve cd status and activate fnm in noninteractive shells --- src/sh.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sh.rs b/src/sh.rs index 3b857e45..077ccd5f 100644 --- a/src/sh.rs +++ b/src/sh.rs @@ -341,7 +341,7 @@ pub fn hbid(a: &App, h: &str) -> String { ho(a, h).map(|x| hb(a, &x)).unwrap_or_else(|| "/work".into()) } -pub const PRE: &str = "ulimit -n 10240 2>/dev/null; export PATH=\"$HOME/.cargo/bin:$HOME/.local/bin:$HOME/go/bin:/usr/local/go/bin:/opt/homebrew/bin:/usr/local/bin:$PATH\" CARGO_TERM_COLOR=never NO_COLOR=1 CI=1 GIT_TERMINAL_PROMPT=0 CARGO_PROFILE_DEV_DEBUG=line-tables-only CARGO_PROFILE_TEST_DEBUG=line-tables-only CARGO_PROFILE_RELEASE_LTO=off CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16 CARGO_PROFILE_BENCH_LTO=off; to() { s=$1; shift; if command -v timeout >/dev/null 2>&1 && timeout --version 2>/dev/null | head -n 1 | grep -q 'coreutils'; then timeout -k 10 \"$s\" \"$@\"; else \"$@\"; fi; }\nif [ \"${APOLLO_OFFICE_FNM:-}\" = 1 ] && command -v fnm >/dev/null 2>&1; then eval \"$(fnm env --shell bash --use-on-cd --resolve-engines --version-file-strategy recursive)\"; fi\n"; +pub const PRE: &str = "ulimit -n 10240 2>/dev/null; export PATH=\"$HOME/.cargo/bin:$HOME/.local/bin:$HOME/go/bin:/usr/local/go/bin:/opt/homebrew/bin:/usr/local/bin:$PATH\" CARGO_TERM_COLOR=never NO_COLOR=1 CI=1 GIT_TERMINAL_PROMPT=0 CARGO_PROFILE_DEV_DEBUG=line-tables-only CARGO_PROFILE_TEST_DEBUG=line-tables-only CARGO_PROFILE_RELEASE_LTO=off CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16 CARGO_PROFILE_BENCH_LTO=off; to() { s=$1; shift; if command -v timeout >/dev/null 2>&1 && timeout --version 2>/dev/null | head -n 1 | grep -q 'coreutils'; then timeout -k 10 \"$s\" \"$@\"; else \"$@\"; fi; }\nif [ \"${APOLLO_OFFICE_FNM:-}\" = 1 ] && command -v fnm >/dev/null 2>&1; then eval \"$(fnm env --shell bash --resolve-engines --version-file-strategy recursive)\"; cd() { builtin cd \"$@\" || return $?; fnm use --silent-if-unchanged >/dev/null 2>&1 || true; }; fi\n"; fn sshv(h: &Ho) -> Vec { let mut v: Vec = vec!["-o".into(), "ConnectTimeout=15".into(), "-o".into(), "ServerAliveInterval=15".into(), "-o".into(), "ServerAliveCountMax=4".into(), "-o".into(), "BatchMode=yes".into()]; From d7a85fbce1116e2c0f9e82be50d11d852f0524bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Sun, 15 Nov 2026 20:46:34 +0000 Subject: [PATCH 09/21] test(worker): cover nonblocking fnm activation in Bash --- src/sh.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/sh.rs b/src/sh.rs index 077ccd5f..6d2ae2c9 100644 --- a/src/sh.rs +++ b/src/sh.rs @@ -571,6 +571,45 @@ mod tests { assert_eq!(super::clip("short", 6000), "short"); } + + #[cfg(unix)] + #[test] + fn fnm_activation_does_not_turn_successful_cd_into_a_failure() { + use std::os::unix::fs::PermissionsExt; + + let root = std::env::temp_dir().join(format!( + "apollo-fnm-cd-{}-{}", + std::process::id(), + hex::encode(rand::random::<[u8; 8]>()) + )); + let bin = root.join("bin"); + std::fs::create_dir_all(&bin).unwrap(); + let fnm = bin.join("fnm"); + // Simulate a valid fnm shell environment, but an unavailable Node pin. + std::fs::write( + &fnm, + "#!/bin/sh\\nif [ \\"$1\\" = env ]; then echo 'export FNM_MULTISHELL_PATH=/tmp/apollo-fnm-test'; exit 0; fi\\nexit 9\\n", + ).unwrap(); + let mut permissions = std::fs::metadata(&fnm).unwrap().permissions(); + permissions.set_mode(0o700); + std::fs::set_permissions(&fnm, permissions).unwrap(); + + let script = format!( + "{PRE}cd {} && printf 'entered\\n'; cd /this-directory-must-not-exist-ao-fnm-test >/dev/null 2>&1 && echo invalid || echo denied", + q(&root.display().to_string()) + ); + let output = std::process::Command::new("/bin/bash") + .arg("-c") + .arg(script) + .env("APOLLO_OFFICE_FNM", "1") + .env("PATH", format!("{}:{}", bin.display(), std::env::var("PATH").unwrap_or_default())) + .output() + .unwrap(); + let _ = std::fs::remove_dir_all(root); + assert!(output.status.success(), "{}", String::from_utf8_lossy(&output.stderr)); + assert_eq!(String::from_utf8_lossy(&output.stdout), "entered\\ndenied\\n"); + } + #[cfg(unix)] #[tokio::test] async fn timeout_kills_child_processes() { From be6de632b3f8cfca7ef17b8b7527a096bc4c25f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Sun, 15 Nov 2026 20:47:02 +0000 Subject: [PATCH 10/21] fix(test): correct Rust shell fixture string escapes --- src/sh.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sh.rs b/src/sh.rs index 6d2ae2c9..1f312181 100644 --- a/src/sh.rs +++ b/src/sh.rs @@ -588,14 +588,14 @@ mod tests { // Simulate a valid fnm shell environment, but an unavailable Node pin. std::fs::write( &fnm, - "#!/bin/sh\\nif [ \\"$1\\" = env ]; then echo 'export FNM_MULTISHELL_PATH=/tmp/apollo-fnm-test'; exit 0; fi\\nexit 9\\n", + "#!/bin/sh\nif [ \"$1\" = env ]; then echo 'export FNM_MULTISHELL_PATH=/tmp/apollo-fnm-test'; exit 0; fi\nexit 9\n", ).unwrap(); let mut permissions = std::fs::metadata(&fnm).unwrap().permissions(); permissions.set_mode(0o700); std::fs::set_permissions(&fnm, permissions).unwrap(); let script = format!( - "{PRE}cd {} && printf 'entered\\n'; cd /this-directory-must-not-exist-ao-fnm-test >/dev/null 2>&1 && echo invalid || echo denied", + "{PRE}cd {} && printf 'entered\n'; cd /this-directory-must-not-exist-ao-fnm-test >/dev/null 2>&1 && echo invalid || echo denied", q(&root.display().to_string()) ); let output = std::process::Command::new("/bin/bash") @@ -607,7 +607,7 @@ mod tests { .unwrap(); let _ = std::fs::remove_dir_all(root); assert!(output.status.success(), "{}", String::from_utf8_lossy(&output.stderr)); - assert_eq!(String::from_utf8_lossy(&output.stdout), "entered\\ndenied\\n"); + assert_eq!(String::from_utf8_lossy(&output.stdout), "entered\ndenied\n"); } #[cfg(unix)] From ddaa7d3b3b551ed609a6db09f3ce198eabc4a42d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Sun, 15 Nov 2026 20:47:52 +0000 Subject: [PATCH 11/21] fix(test): qualify shell helpers in isolated test module --- src/sh.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sh.rs b/src/sh.rs index 1f312181..4ce23a74 100644 --- a/src/sh.rs +++ b/src/sh.rs @@ -595,8 +595,9 @@ mod tests { std::fs::set_permissions(&fnm, permissions).unwrap(); let script = format!( - "{PRE}cd {} && printf 'entered\n'; cd /this-directory-must-not-exist-ao-fnm-test >/dev/null 2>&1 && echo invalid || echo denied", - q(&root.display().to_string()) + "{}cd {} && printf 'entered\n'; cd /this-directory-must-not-exist-ao-fnm-test >/dev/null 2>&1 && echo invalid || echo denied", + super::PRE, + super::q(&root.display().to_string()) ); let output = std::process::Command::new("/bin/bash") .arg("-c") From 1d1add62ea45b39762a0e9831f28c2f456725940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Sun, 15 Nov 2026 20:48:27 +0000 Subject: [PATCH 12/21] build: pin fnm release for reproducible worker images --- src/sh.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sh.rs b/src/sh.rs index 4ce23a74..6bc33c62 100644 --- a/src/sh.rs +++ b/src/sh.rs @@ -426,7 +426,7 @@ COPY --from=node24 /usr/local/include/node /usr/local/include/node RUN ln -sf ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ && ln -sf ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \ && curl -fsSL https://fnm.vercel.app/install -o /tmp/install-fnm.sh \ - && bash /tmp/install-fnm.sh --install-dir /usr/local/bin --skip-shell \ + && bash /tmp/install-fnm.sh --install-dir /usr/local/bin --skip-shell --release v1.39.0 \ && rm -f /tmp/install-fnm.sh \ && node --version | grep -Eq '^v24\.' \ && npm --version >/dev/null && fnm --version >/dev/null From 9e8ca8ac6f5e1f54e180a974d3598bd48a93bbc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Sun, 15 Nov 2026 20:48:54 +0000 Subject: [PATCH 13/21] test(pipe): cover LTS alias delegation to fnm --- src/pipe.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pipe.rs b/src/pipe.rs index a7b546c3..ab12e034 100644 --- a/src/pipe.rs +++ b/src/pipe.rs @@ -1952,6 +1952,10 @@ mod t { assert!(pinned.status.success()); assert!(String::from_utf8_lossy(&pinned.stdout).contains("fnm-called: use --install-if-missing --resolve-engines")); + let alias = run_node_script(NODE_VERSION_SELECTION, Some("lts/iron\n"), None, None, true); + assert!(alias.status.success()); + assert!(String::from_utf8_lossy(&alias.stdout).contains("fnm-called: use")); + let node_version = run_node_script(NODE_VERSION_SELECTION, None, Some("22\n"), None, true); assert!(node_version.status.success()); assert!(String::from_utf8_lossy(&node_version.stdout).contains("fnm-called: use")); From 0f6b28b46edef79476d22e586053955246e627f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Sun, 15 Nov 2026 20:50:58 +0000 Subject: [PATCH 14/21] test(worker): isolate fnm fixture from host PATH --- src/sh.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sh.rs b/src/sh.rs index 6bc33c62..0f911e52 100644 --- a/src/sh.rs +++ b/src/sh.rs @@ -582,7 +582,7 @@ mod tests { std::process::id(), hex::encode(rand::random::<[u8; 8]>()) )); - let bin = root.join("bin"); + let bin = root.join(".local").join("bin"); std::fs::create_dir_all(&bin).unwrap(); let fnm = bin.join("fnm"); // Simulate a valid fnm shell environment, but an unavailable Node pin. @@ -603,6 +603,7 @@ mod tests { .arg("-c") .arg(script) .env("APOLLO_OFFICE_FNM", "1") + .env("HOME", &root) .env("PATH", format!("{}:{}", bin.display(), std::env::var("PATH").unwrap_or_default())) .output() .unwrap(); From 0ee5ed7d919f26eddb3ef14b18dce14e33aac817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Mon, 16 Nov 2026 15:24:28 +0000 Subject: [PATCH 15/21] fix(worker): verified fnm archives, system default and one multishell per job --- src/sh.rs | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/sh.rs b/src/sh.rs index 0f911e52..c3ebec86 100644 --- a/src/sh.rs +++ b/src/sh.rs @@ -341,7 +341,7 @@ pub fn hbid(a: &App, h: &str) -> String { ho(a, h).map(|x| hb(a, &x)).unwrap_or_else(|| "/work".into()) } -pub const PRE: &str = "ulimit -n 10240 2>/dev/null; export PATH=\"$HOME/.cargo/bin:$HOME/.local/bin:$HOME/go/bin:/usr/local/go/bin:/opt/homebrew/bin:/usr/local/bin:$PATH\" CARGO_TERM_COLOR=never NO_COLOR=1 CI=1 GIT_TERMINAL_PROMPT=0 CARGO_PROFILE_DEV_DEBUG=line-tables-only CARGO_PROFILE_TEST_DEBUG=line-tables-only CARGO_PROFILE_RELEASE_LTO=off CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16 CARGO_PROFILE_BENCH_LTO=off; to() { s=$1; shift; if command -v timeout >/dev/null 2>&1 && timeout --version 2>/dev/null | head -n 1 | grep -q 'coreutils'; then timeout -k 10 \"$s\" \"$@\"; else \"$@\"; fi; }\nif [ \"${APOLLO_OFFICE_FNM:-}\" = 1 ] && command -v fnm >/dev/null 2>&1; then eval \"$(fnm env --shell bash --resolve-engines --version-file-strategy recursive)\"; cd() { builtin cd \"$@\" || return $?; fnm use --silent-if-unchanged >/dev/null 2>&1 || true; }; fi\n"; +pub const PRE: &str = "ulimit -n 10240 2>/dev/null; export PATH=\"$HOME/.cargo/bin:$HOME/.local/bin:$HOME/go/bin:/usr/local/go/bin:/opt/homebrew/bin:/usr/local/bin:$PATH\" CARGO_TERM_COLOR=never NO_COLOR=1 CI=1 GIT_TERMINAL_PROMPT=0 CARGO_PROFILE_DEV_DEBUG=line-tables-only CARGO_PROFILE_TEST_DEBUG=line-tables-only CARGO_PROFILE_RELEASE_LTO=off CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16 CARGO_PROFILE_BENCH_LTO=off; to() { s=$1; shift; if command -v timeout >/dev/null 2>&1 && timeout --version 2>/dev/null | head -n 1 | grep -q 'coreutils'; then timeout -k 10 \"$s\" \"$@\"; else \"$@\"; fi; }\nif [ \"${APOLLO_OFFICE_FNM:-}\" = 1 ] && command -v fnm >/dev/null 2>&1; then _ao_fnm_env=$(fnm env --shell bash --resolve-engines --version-file-strategy recursive) && { eval \"$_ao_fnm_env\"; _ao_fnm_link=${FNM_MULTISHELL_PATH:-}; trap 'if [ -L \"$_ao_fnm_link\" ]; then rm -f -- \"$_ao_fnm_link\"; fi' EXIT; cd() { builtin cd \"$@\" || return $?; fnm use --silent-if-unchanged >/dev/null 2>&1 || true; }; }; fi\n"; fn sshv(h: &Ho) -> Vec { let mut v: Vec = vec!["-o".into(), "ConnectTimeout=15".into(), "-o".into(), "ServerAliveInterval=15".into(), "-o".into(), "ServerAliveCountMax=4".into(), "-o".into(), "BatchMode=yes".into()]; @@ -389,7 +389,9 @@ async fn hxo(a: &App, id: &str, s: &str, t: u64, ln: Option<&(dyn Fn(&str) + Sen // active everywhere, including Windows/macOS without GNU coreutils timeout. let boundary=format!("APOLLO_JOB_{}",hex::encode(rand::random::<[u8;16]>())); let body=format!("if command -v timeout >/dev/null 2>&1 && timeout --version 2>/dev/null | head -n 1 | grep -q 'coreutils'; then exec timeout -k 5 {t}s bash -s; else exec bash -s; fi <<'{boundary}'\n{PRE}{s}\n{boundary}\n"); - let i = format!("{PRE}{}{body}", jobs(a, &h)); + // Only the inner Bash session initializes fnm; its exit trap removes + // its own multishell symlink after the command has completed. + let i = format!("{}{body}", jobs(a, &h)); let mut command: Vec = if h.dk { vec!["docker".into(), "exec".into(), "-i".into(), CT.into()] } else { vec![] }; command.extend(["bash".into(), "-s".into()]); let (p, v) = if h.ssh.is_empty() { @@ -425,13 +427,26 @@ COPY --from=node24 /usr/local/lib/node_modules /usr/local/lib/node_modules COPY --from=node24 /usr/local/include/node /usr/local/include/node RUN ln -sf ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ && ln -sf ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \ - && curl -fsSL https://fnm.vercel.app/install -o /tmp/install-fnm.sh \ - && bash /tmp/install-fnm.sh --install-dir /usr/local/bin --skip-shell --release v1.39.0 \ - && rm -f /tmp/install-fnm.sh \ - && node --version | grep -Eq '^v24\.' \ - && npm --version >/dev/null && fnm --version >/dev/null + && npm --version >/dev/null +# Install an immutable, checksum-verified fnm v1.39.0 release archive. +RUN set -eu; \ + case "$(dpkg --print-architecture)" in \ + amd64) asset=fnm-linux.zip; checksum=7807664f39d39fc518da1c35ba0181e4b3267603c4b1dedeb4b5fc6ae440a224 ;; \ + arm64) asset=fnm-arm64.zip; checksum=4eaff58b2c5bf30d0934027572dd0b5bbb60d2a1af309230b53662d4b1d45599 ;; \ + *) echo "Unsupported architecture for fnm release" >&2; exit 1 ;; \ + esac; \ + curl --fail --location --retry 3 --silent --show-error "https://github.com/Schniz/fnm/releases/download/v1.39.0/$asset" -o /tmp/fnm.zip; \ + echo "$checksum /tmp/fnm.zip" | sha256sum --check --status; \ + unzip -j /tmp/fnm.zip fnm -d /usr/local/bin; \ + chmod 755 /usr/local/bin/fnm; \ + rm /tmp/fnm.zip; \ + fnm --version; \ + node --version | grep -Eq '^v24\\.' +# Prevent installing a project-specific version from changing the image default. +ENV FNM_DIR=/opt/apollo-fnm +RUN fnm alias system default RUN rustup component add rustfmt clippy && rustup target add wasm32-unknown-unknown && npm install -g pnpm yarn && pip3 install --break-system-packages pytest -ENV CARGO_TERM_COLOR=never CARGO_INCREMENTAL=0 PIP_BREAK_SYSTEM_PACKAGES=1 APOLLO_OFFICE_FNM=1 FNM_DIR=/opt/apollo-fnm +ENV CARGO_TERM_COLOR=never CARGO_INCREMENTAL=0 PIP_BREAK_SYSTEM_PACKAGES=1 APOLLO_OFFICE_FNM=1 WORKDIR /work "#; From a4cb4b5bf111251e44803f8f7bba30fac4fa45c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Mon, 16 Nov 2026 15:24:45 +0000 Subject: [PATCH 16/21] fix(build): correct Node 24 version assertion --- src/sh.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sh.rs b/src/sh.rs index c3ebec86..48371050 100644 --- a/src/sh.rs +++ b/src/sh.rs @@ -441,7 +441,7 @@ RUN set -eu; \ chmod 755 /usr/local/bin/fnm; \ rm /tmp/fnm.zip; \ fnm --version; \ - node --version | grep -Eq '^v24\\.' + node --version | grep -Eq '^v24\.' # Prevent installing a project-specific version from changing the image default. ENV FNM_DIR=/opt/apollo-fnm RUN fnm alias system default From d2e341a07871c590238eb5cd29f3dcfc546b2d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Mon, 16 Nov 2026 15:25:56 +0000 Subject: [PATCH 17/21] test(worker): verify fnm multishell symlink cleanup on shell exit --- src/sh.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/sh.rs b/src/sh.rs index 48371050..3aeee875 100644 --- a/src/sh.rs +++ b/src/sh.rs @@ -590,7 +590,7 @@ mod tests { #[cfg(unix)] #[test] fn fnm_activation_does_not_turn_successful_cd_into_a_failure() { - use std::os::unix::fs::PermissionsExt; + use std::os::unix::fs::{symlink, PermissionsExt}; let root = std::env::temp_dir().join(format!( "apollo-fnm-cd-{}-{}", @@ -599,11 +599,15 @@ mod tests { )); let bin = root.join(".local").join("bin"); std::fs::create_dir_all(&bin).unwrap(); + let target = root.join("node-24"); + std::fs::create_dir_all(&target).unwrap(); + let multishell = root.join("fnm-multishell"); + symlink(&target, &multishell).unwrap(); let fnm = bin.join("fnm"); // Simulate a valid fnm shell environment, but an unavailable Node pin. std::fs::write( &fnm, - "#!/bin/sh\nif [ \"$1\" = env ]; then echo 'export FNM_MULTISHELL_PATH=/tmp/apollo-fnm-test'; exit 0; fi\nexit 9\n", + "#!/bin/sh\nif [ \"$1\" = env ]; then printf 'export FNM_MULTISHELL_PATH=%s\\n' \"$APOLLO_TEST_MULTISHELL\"; exit 0; fi\nexit 9\n", ).unwrap(); let mut permissions = std::fs::metadata(&fnm).unwrap().permissions(); permissions.set_mode(0o700); @@ -618,11 +622,14 @@ mod tests { .arg("-c") .arg(script) .env("APOLLO_OFFICE_FNM", "1") + .env("APOLLO_TEST_MULTISHELL", &multishell) .env("HOME", &root) .env("PATH", format!("{}:{}", bin.display(), std::env::var("PATH").unwrap_or_default())) .output() .unwrap(); + let cleaned = std::fs::symlink_metadata(&multishell).is_err(); let _ = std::fs::remove_dir_all(root); + assert!(cleaned, "fnm multishell symlink leaked after the Bash command"); assert!(output.status.success(), "{}", String::from_utf8_lossy(&output.stderr)); assert_eq!(String::from_utf8_lossy(&output.stdout), "entered\ndenied\n"); } From e5d9cc6a9469fc4302270c17443df80932a218fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Mon, 16 Nov 2026 15:26:50 +0000 Subject: [PATCH 18/21] ci: build real worker image and verify Node 24 after installing Node 20 --- .github/workflows/ci.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dbbeb933..4b8fb04f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,3 +25,37 @@ jobs: run: | python3 -m unittest discover -s quality -p 'test_*.py' python3 -m unittest discover -s adapters/opencode -p 'test_*.py' + + worker-image: + name: Worker image — Node 24 and fnm + runs-on: ubuntu-latest + timeout-minutes: 45 + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - name: Extract embedded Dockerfile + run: | + python3 - <<'PY' + from pathlib import Path + source = Path("src/sh.rs").read_text(encoding="utf-8") + prefix = 'pub const DF: &str = r#"' + assert source.count(prefix) == 1, "expected one worker Dockerfile" + dockerfile = source.split(prefix, 1)[1].split('"#;', 1)[0] + Path("worker.Dockerfile").write_text(dockerfile, encoding="utf-8") + PY + - name: Build actual worker image + run: docker build --pull -t apollo-office-worker-smoke -f worker.Dockerfile . + - name: Verify image Node and cross-repository fnm defaults + run: | + docker run --rm apollo-office-worker-smoke bash -euc ' + node --version | grep -Eq "^v24\\." + fnm --version + mkdir -p /work/uses-node-20 /work/no-node-version + printf "20\\n" > /work/uses-node-20/.nvmrc + eval "$(fnm env --shell bash --resolve-engines)" + cd /work/uses-node-20 + fnm use --install-if-missing + node --version | grep -Eq "^v20\\." + cd /work/no-node-version + fnm use + node --version | grep -Eq "^v24\\." + ' From da6d74a9b61e8a1e3eddcab477c744cca64e59ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gomes?= Date: Mon, 16 Nov 2026 15:29:36 +0000 Subject: [PATCH 19/21] ci: print Node 24 version in worker image smoke logs --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b8fb04f..2081a60c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,7 @@ jobs: - name: Verify image Node and cross-repository fnm defaults run: | docker run --rm apollo-office-worker-smoke bash -euc ' + node --version node --version | grep -Eq "^v24\\." fnm --version mkdir -p /work/uses-node-20 /work/no-node-version @@ -57,5 +58,6 @@ jobs: node --version | grep -Eq "^v20\\." cd /work/no-node-version fnm use + node --version node --version | grep -Eq "^v24\\." ' From 101a9aef2942bf2f39798727da50746b199d6602 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Mon, 16 Nov 2026 17:52:43 +0100 Subject: [PATCH 20/21] fix(worker): fall back to the default Node when a directory has no version file The cd hook kept the previous repository's Node when fnm found no version file. Fall back to the default alias, mirror the hook in the image smoke test, and stop prefixing PRE twice for cargo install. --- .github/workflows/ci.yml | 5 +++-- src/pipe.rs | 2 +- src/sh.rs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2081a60c..2da5f738 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,12 +52,13 @@ jobs: fnm --version mkdir -p /work/uses-node-20 /work/no-node-version printf "20\\n" > /work/uses-node-20/.nvmrc - eval "$(fnm env --shell bash --resolve-engines)" + eval "$(fnm env --shell bash --resolve-engines --version-file-strategy recursive)" + hook() { fnm use --silent-if-unchanged || fnm use --silent-if-unchanged default; } cd /work/uses-node-20 fnm use --install-if-missing node --version | grep -Eq "^v20\\." cd /work/no-node-version - fnm use + hook node --version node --version | grep -Eq "^v24\\." ' diff --git a/src/pipe.rs b/src/pipe.rs index ab12e034..da88c6ce 100644 --- a/src/pipe.rs +++ b/src/pipe.rs @@ -604,7 +604,7 @@ async fn ci0(a: &Ax, j: &mut Job) -> R { if let Some(k) = t.1.filter(|_| !it) { it = true; a.say("ci", &format!("[{}] {c} needs {k}, installing it", j.h()), Some(j.id)); - let r = hx(a, &j.h(), &format!("{}cargo install {} --locked 2>&1 | tail -3", crate::sh::PRE, q(&k)), 2400).await; + let r = hx(a, &j.h(), &format!("cargo install {} --locked 2>&1 | tail -3", q(&k)), 2400).await; if r.c == 0 { continue; } diff --git a/src/sh.rs b/src/sh.rs index 3aeee875..bdc9169c 100644 --- a/src/sh.rs +++ b/src/sh.rs @@ -341,7 +341,7 @@ pub fn hbid(a: &App, h: &str) -> String { ho(a, h).map(|x| hb(a, &x)).unwrap_or_else(|| "/work".into()) } -pub const PRE: &str = "ulimit -n 10240 2>/dev/null; export PATH=\"$HOME/.cargo/bin:$HOME/.local/bin:$HOME/go/bin:/usr/local/go/bin:/opt/homebrew/bin:/usr/local/bin:$PATH\" CARGO_TERM_COLOR=never NO_COLOR=1 CI=1 GIT_TERMINAL_PROMPT=0 CARGO_PROFILE_DEV_DEBUG=line-tables-only CARGO_PROFILE_TEST_DEBUG=line-tables-only CARGO_PROFILE_RELEASE_LTO=off CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16 CARGO_PROFILE_BENCH_LTO=off; to() { s=$1; shift; if command -v timeout >/dev/null 2>&1 && timeout --version 2>/dev/null | head -n 1 | grep -q 'coreutils'; then timeout -k 10 \"$s\" \"$@\"; else \"$@\"; fi; }\nif [ \"${APOLLO_OFFICE_FNM:-}\" = 1 ] && command -v fnm >/dev/null 2>&1; then _ao_fnm_env=$(fnm env --shell bash --resolve-engines --version-file-strategy recursive) && { eval \"$_ao_fnm_env\"; _ao_fnm_link=${FNM_MULTISHELL_PATH:-}; trap 'if [ -L \"$_ao_fnm_link\" ]; then rm -f -- \"$_ao_fnm_link\"; fi' EXIT; cd() { builtin cd \"$@\" || return $?; fnm use --silent-if-unchanged >/dev/null 2>&1 || true; }; }; fi\n"; +pub const PRE: &str = "ulimit -n 10240 2>/dev/null; export PATH=\"$HOME/.cargo/bin:$HOME/.local/bin:$HOME/go/bin:/usr/local/go/bin:/opt/homebrew/bin:/usr/local/bin:$PATH\" CARGO_TERM_COLOR=never NO_COLOR=1 CI=1 GIT_TERMINAL_PROMPT=0 CARGO_PROFILE_DEV_DEBUG=line-tables-only CARGO_PROFILE_TEST_DEBUG=line-tables-only CARGO_PROFILE_RELEASE_LTO=off CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16 CARGO_PROFILE_BENCH_LTO=off; to() { s=$1; shift; if command -v timeout >/dev/null 2>&1 && timeout --version 2>/dev/null | head -n 1 | grep -q 'coreutils'; then timeout -k 10 \"$s\" \"$@\"; else \"$@\"; fi; }\nif [ \"${APOLLO_OFFICE_FNM:-}\" = 1 ] && command -v fnm >/dev/null 2>&1; then _ao_fnm_env=$(fnm env --shell bash --resolve-engines --version-file-strategy recursive) && { eval \"$_ao_fnm_env\"; _ao_fnm_link=${FNM_MULTISHELL_PATH:-}; trap 'if [ -L \"$_ao_fnm_link\" ]; then rm -f -- \"$_ao_fnm_link\"; fi' EXIT; cd() { builtin cd \"$@\" || return $?; fnm use --silent-if-unchanged >/dev/null 2>&1 || fnm use --silent-if-unchanged default >/dev/null 2>&1 || true; }; }; fi\n"; fn sshv(h: &Ho) -> Vec { let mut v: Vec = vec!["-o".into(), "ConnectTimeout=15".into(), "-o".into(), "ServerAliveInterval=15".into(), "-o".into(), "ServerAliveCountMax=4".into(), "-o".into(), "BatchMode=yes".into()]; From af86c8302b90de78c459f6a438baa7022710ae01 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Mon, 16 Nov 2026 17:58:33 +0100 Subject: [PATCH 21/21] fix(worker): use the system Node when no version file is found fnm moves its default alias to every newly installed version, so a 'system' default does not survive the first install and the cd hook fell back to whatever another repository installed last. Look for .nvmrc/.node-version up the tree and select the system Node otherwise, also when the shell starts. The image smoke test now sources the real PRE prelude instead of a copy of the hook. --- .github/workflows/ci.yml | 21 +++++++++++++-------- src/sh.rs | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2da5f738..92ff6941 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,24 +41,29 @@ jobs: assert source.count(prefix) == 1, "expected one worker Dockerfile" dockerfile = source.split(prefix, 1)[1].split('"#;', 1)[0] Path("worker.Dockerfile").write_text(dockerfile, encoding="utf-8") + prefix = 'pub const PRE: &str = "' + assert source.count(prefix) == 1, "expected one shell prelude" + pre = source.split(prefix, 1)[1].split('";\n', 1)[0] + Path("pre.sh").write_text(pre.encode().decode("unicode_escape"), encoding="utf-8") PY - name: Build actual worker image run: docker build --pull -t apollo-office-worker-smoke -f worker.Dockerfile . - name: Verify image Node and cross-repository fnm defaults run: | - docker run --rm apollo-office-worker-smoke bash -euc ' - node --version + docker run --rm -v "$PWD/pre.sh:/pre.sh:ro" apollo-office-worker-smoke bash -euc ' node --version | grep -Eq "^v24\\." fnm --version - mkdir -p /work/uses-node-20 /work/no-node-version + mkdir -p /work/uses-node-20/sub /work/uses-node-22 /work/no-node-version printf "20\\n" > /work/uses-node-20/.nvmrc - eval "$(fnm env --shell bash --resolve-engines --version-file-strategy recursive)" - hook() { fnm use --silent-if-unchanged || fnm use --silent-if-unchanged default; } - cd /work/uses-node-20 - fnm use --install-if-missing + printf "22\\n" > /work/uses-node-22/.nvmrc + . /pre.sh + for d in /work/uses-node-20 /work/uses-node-22; do (cd "$d" && fnm use --install-if-missing); done + cd /work/uses-node-20/sub node --version | grep -Eq "^v20\\." + cd /work/uses-node-22 + node --version | grep -Eq "^v22\\." cd /work/no-node-version - hook node --version node --version | grep -Eq "^v24\\." + bash -c ". /pre.sh; node --version" | grep -Eq "^v24\\." ' diff --git a/src/sh.rs b/src/sh.rs index bdc9169c..4e1d80ae 100644 --- a/src/sh.rs +++ b/src/sh.rs @@ -341,7 +341,7 @@ pub fn hbid(a: &App, h: &str) -> String { ho(a, h).map(|x| hb(a, &x)).unwrap_or_else(|| "/work".into()) } -pub const PRE: &str = "ulimit -n 10240 2>/dev/null; export PATH=\"$HOME/.cargo/bin:$HOME/.local/bin:$HOME/go/bin:/usr/local/go/bin:/opt/homebrew/bin:/usr/local/bin:$PATH\" CARGO_TERM_COLOR=never NO_COLOR=1 CI=1 GIT_TERMINAL_PROMPT=0 CARGO_PROFILE_DEV_DEBUG=line-tables-only CARGO_PROFILE_TEST_DEBUG=line-tables-only CARGO_PROFILE_RELEASE_LTO=off CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16 CARGO_PROFILE_BENCH_LTO=off; to() { s=$1; shift; if command -v timeout >/dev/null 2>&1 && timeout --version 2>/dev/null | head -n 1 | grep -q 'coreutils'; then timeout -k 10 \"$s\" \"$@\"; else \"$@\"; fi; }\nif [ \"${APOLLO_OFFICE_FNM:-}\" = 1 ] && command -v fnm >/dev/null 2>&1; then _ao_fnm_env=$(fnm env --shell bash --resolve-engines --version-file-strategy recursive) && { eval \"$_ao_fnm_env\"; _ao_fnm_link=${FNM_MULTISHELL_PATH:-}; trap 'if [ -L \"$_ao_fnm_link\" ]; then rm -f -- \"$_ao_fnm_link\"; fi' EXIT; cd() { builtin cd \"$@\" || return $?; fnm use --silent-if-unchanged >/dev/null 2>&1 || fnm use --silent-if-unchanged default >/dev/null 2>&1 || true; }; }; fi\n"; +pub const PRE: &str = "ulimit -n 10240 2>/dev/null; export PATH=\"$HOME/.cargo/bin:$HOME/.local/bin:$HOME/go/bin:/usr/local/go/bin:/opt/homebrew/bin:/usr/local/bin:$PATH\" CARGO_TERM_COLOR=never NO_COLOR=1 CI=1 GIT_TERMINAL_PROMPT=0 CARGO_PROFILE_DEV_DEBUG=line-tables-only CARGO_PROFILE_TEST_DEBUG=line-tables-only CARGO_PROFILE_RELEASE_LTO=off CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16 CARGO_PROFILE_BENCH_LTO=off; to() { s=$1; shift; if command -v timeout >/dev/null 2>&1 && timeout --version 2>/dev/null | head -n 1 | grep -q 'coreutils'; then timeout -k 10 \"$s\" \"$@\"; else \"$@\"; fi; }\nif [ \"${APOLLO_OFFICE_FNM:-}\" = 1 ] && command -v fnm >/dev/null 2>&1; then _ao_fnm_env=$(fnm env --shell bash --resolve-engines --version-file-strategy recursive) && { eval \"$_ao_fnm_env\"; _ao_fnm_link=${FNM_MULTISHELL_PATH:-}; trap 'if [ -L \"$_ao_fnm_link\" ]; then rm -f -- \"$_ao_fnm_link\"; fi' EXIT; _ao_node() { local d=$PWD; while :; do if [ -f \"$d/.nvmrc\" ] || [ -f \"$d/.node-version\" ]; then fnm use --silent-if-unchanged >/dev/null 2>&1; break; fi; if [ \"$d\" = / ]; then fnm use --silent-if-unchanged system >/dev/null 2>&1; break; fi; d=${d%/*}; d=${d:-/}; done; hash -r; }; cd() { builtin cd \"$@\" || return $?; _ao_node || true; }; _ao_node || true; }; fi\n"; fn sshv(h: &Ho) -> Vec { let mut v: Vec = vec!["-o".into(), "ConnectTimeout=15".into(), "-o".into(), "ServerAliveInterval=15".into(), "-o".into(), "ServerAliveCountMax=4".into(), "-o".into(), "BatchMode=yes".into()];