{"record":{"id":"a44d4f3a2a5efd3d","repo":"vercel/turborepo","slug":"failed-to-execute-turbo-via-npx","errorCode":null,"errorMessage":"Failed to execute `turbo` via `npx`.","messagePattern":"Failed to execute `turbo` via `npx`\\.","errorType":"exception","errorClass":"NpxTurboProcess","httpStatus":null,"severity":"error","filePath":"crates/turborepo-shim/src/run.rs","lineNumber":524,"sourceCode":"    raw_args.append(&mut shim_args.forwarded_args);\n\n    raw_args\n}\n\nfn spawn_child_turbo<R, C, S, V>(\n    runtime: &ShimRuntime<R, C, S, V>,\n    command: process::Command,\n    err: fn(std::io::Error) -> Error,\n) -> ShimResult<R::Error>\nwhere\n    R: TurboRunner,\n    C: ConfigProvider,\n    S: ChildSpawner,\n    V: VersionProvider,\n{\n    let child: Arc<SharedChild> = match runtime.child_spawner.spawn(command) {\n        Ok(child) => child,\n        Err(e) => return ShimResult::ShimError(err(e)),\n    };\n\n    // The child turbo process shares our process group and will receive\n    // SIGINT directly from the kernel when the user presses Ctrl+C.\n    // Ignore SIGINT in the shim *after* spawning so the child inherits\n    // the default disposition (and can register its own handler), while\n    // the shim stays alive to collect the child's exit status.\n    #[cfg(unix)]\n    unsafe {\n        libc::signal(libc::SIGINT, libc::SIG_IGN);\n    }\n\n    let exit_status = match child.wait() {\n        Ok(status) => status,\n        Err(e) => return ShimResult::ShimError(err(e)),\n    };\n    let exit_code = exit_status.code().unwrap_or_else(|| {\n        debug!(\"child turbo failed to report exit code\");","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/vercel/turborepo/blob/f9245100cf0d31d96628804ead485f6bf226e55a/crates/turborepo-shim/src/run.rs#L506-L542","documentation":"The shim's fallback path runs `npx turbo` when no usable local turbo exists; the spawn itself (runtime.child_spawner.spawn, run.rs:524 region) failed at the OS level and is wrapped as Error::NpxTurboProcess with the io::Error as #[source] (run.rs:114-115). Note the distinction: `which` failing to find npx is a separate Error::Which — this error means npx was found but exec'ing it failed.","triggerScenarios":"Spawning `npx turbo` fails with EACCES (npx shim not executable), ENOENT/ENOEXEC (Node was upgraded or moved so the shim's shebang `#!/usr/bin/env node` no longer resolves), or resource exhaustion (EMFILE).","commonSituations":"Node upgraded via nvm/system package and stale npm shims left behind Permissions broken on the global bin dir after a manual copy Running in minimal containers where env/node is absent from the spawn environment","solutions":["Run `npx turbo --version` manually and read the underlying errno — that is the #[source] of this error","Reinstall Node/npm to regenerate the npx shim; check `head -1 $(which npx)` points at an existing node","Install turbo locally in the repo so the shim uses the local binary and never needs the npx fallback","Ensure PATH visible to spawned children includes the node bin directory"],"exampleFix":"# diagnose\nnpx turbo --version\nhead -1 \"$(command -v npx)\"\n# fix: regenerate shims / prefer local install\nnpm install -g npm\npnpm add -w -D turbo","handlingStrategy":"fallback","validationCode":"// verify npx actually executes before relying on the fallback\nlet ok = std::process::Command::new(\"npx\").arg(\"--version\").status().map(|s| s.success()).unwrap_or(false);\nif !ok { install_turbo_locally(); }","typeGuard":null,"tryCatchPattern":"// prefer local turbo; only fall back to npx, and surface the source errno\nmatch run_local_turbo() {\n    ShimResult::ShimError(Error::LocalTurboProcess(_)) | Err(_) => {\n        match run_via_npx() {\n            ShimResult::ShimError(Error::NpxTurboProcess(src)) => handle_errno(src),\n            r => r,\n        }\n    }\n    r => r,\n}","preventionTips":["Install turbo in the repo so the npx fallback never triggers","After Node upgrades, regenerate npm shims (reinstall npm/node)","Ensure the spawn environment's PATH contains the node bin dir"],"tags":["shim","spawn","npx","process","node"],"backgroundTag":"spawn-executable-failed","analyzedSha":"f9245100cf0d31d96628804ead485f6bf226e55a","analyzedAt":"2026-08-17T10:46:15.696Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}