fix: use direct Node.js binary tarball on Fly instead of apt/npm/n (#1637)

Replace the Node.js install chain (apt nodejs+npm → npm install -g n →
n 22 → symlinks) with a single curl of the v22 binary tarball from
nodejs.org. Eliminates python3 dependency, npm bloat, and the n version
manager. Bun is installed first as the primary package manager.

Fly-only change — other clouds unchanged pending validation.

Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
A 2026-02-21 15:44:39 -08:00 committed by GitHub
parent 42f2b66b55
commit ea9bb2bee5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 9 deletions

View file

@ -129,7 +129,7 @@ async function installClaudeCode(): Promise<void> {
`export PATH="${claudePath}:$PATH"`,
`if command -v claude >/dev/null 2>&1; then ${finalize}; exit 0; fi`,
// Ensure Node.js for npm method
`if ! command -v node >/dev/null 2>&1; then DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends nodejs npm 2>/dev/null && npm install -g n && n 22 && ln -sf /usr/local/bin/node /usr/bin/node && ln -sf /usr/local/bin/npm /usr/bin/npm && ln -sf /usr/local/bin/npx /usr/bin/npx || true; fi`,
`if ! command -v node >/dev/null 2>&1; then curl -fsSL https://nodejs.org/dist/v22.15.0/node-v22.15.0-linux-x64.tar.xz | tar -xJ -C /usr/local --strip-components=1 || true; fi`,
// Method 2: npm
`echo "==> Installing Claude Code (method 2/2: npm)..."`,
`npm install -g @anthropic-ai/claude-code || true`,

View file

@ -748,20 +748,21 @@ export async function waitForSsh(maxAttempts = 20): Promise<void> {
export async function waitForCloudInit(): Promise<void> {
await waitForSsh();
logStep("Installing packages (Node.js, bun)...");
logStep("Installing packages (bun, Node.js)...");
// Batch all package installs into a single remote script to avoid multiple
// round-trips (each of which was previously a separate fly machine exec call).
// Install bun first (single binary, no deps), then Node.js as a direct binary
// download from nodejs.org — no apt nodejs/npm/python3, no NodeSource, no n.
const setupScript = [
`echo "==> Installing base packages..."`,
`export DEBIAN_FRONTEND=noninteractive`,
`apt-get update -y && apt-get install -y --no-install-recommends curl unzip git ca-certificates || true`,
`echo "==> Checking Node.js..."`,
`if ! command -v node >/dev/null 2>&1; then apt-get install -y --no-install-recommends nodejs npm || true; fi`,
`npm install -g n && n 22 && ln -sf /usr/local/bin/node /usr/bin/node && ln -sf /usr/local/bin/npm /usr/bin/npm && ln -sf /usr/local/bin/npx /usr/bin/npx || true`,
`echo "node: $(node --version 2>/dev/null || echo not installed)"`,
`apt-get update -y && apt-get install -y --no-install-recommends curl unzip git ca-certificates xz-utils || true`,
`echo "==> Checking bun..."`,
`if ! command -v bun >/dev/null 2>&1 && [ ! -f "$HOME/.bun/bin/bun" ]; then curl -fsSL https://bun.sh/install | bash || true; fi`,
`for rc in ~/.bashrc ~/.zshrc; do grep -q '.bun/bin' "$rc" 2>/dev/null || echo 'export PATH="$HOME/.local/bin:$HOME/.bun/bin:$PATH"' >> "$rc"; done`,
`echo "==> Checking Node.js..."`,
`if ! command -v node >/dev/null 2>&1; then curl -fsSL https://nodejs.org/dist/v22.15.0/node-v22.15.0-linux-x64.tar.xz | tar -xJ -C /usr/local --strip-components=1 || true; fi`,
`echo "node: $(node --version 2>/dev/null || echo not installed)"`,
].join('\n');
try {