{"record":{"id":"238ffa9d2bb42cda","repo":"tauri-apps/tauri","slug":"failed-to-run-before-dev","errorCode":null,"errorMessage":"failed to run `{before_dev}`","messagePattern":"failed to run `(.+?)`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-cli/src/dev.rs","lineNumber":207,"sourceCode":"            \"`{before_dev}` with `{}`\",\n            if cfg!(windows) { \"cmd /S /C\" } else { \"sh -c\" }\n          ),\n          error,\n        })?;\n        if !status.success() {\n          crate::error::bail!(\n            \"beforeDevCommand `{}` failed with exit code {}\",\n            before_dev,\n            status.code().unwrap_or_default()\n          );\n        }\n      } else {\n        command.stdin(Stdio::piped());\n        command.stdout(os_pipe::dup_stdout().unwrap());\n        command.stderr(os_pipe::dup_stderr().unwrap());\n\n        let child = SharedChild::spawn(&mut command)\n          .unwrap_or_else(|_| panic!(\"failed to run `{before_dev}`\"));\n\n        let child = BEFORE_DEV.get_or_init(move || child);\n        std::thread::spawn(move || {\n          let status = child\n            .wait()\n            .expect(\"failed to wait on \\\"beforeDevCommand\\\"\");\n          if !(status.success() || KILL_BEFORE_DEV_FLAG.load(Ordering::SeqCst)) {\n            log::error!(\"The \\\"beforeDevCommand\\\" terminated with a non-zero status code.\");\n            exit(status.code().unwrap_or(1));\n          }\n        });\n\n        let _ = ctrlc::set_handler(move || {\n          kill_before_dev_process();\n          exit(130);\n        });\n      }\n    }","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-cli/src/dev.rs#L189-L225","documentation":"Panic in `tauri dev` when SharedChild::spawn fails to launch the configured build > beforeDevCommand. This is a spawn failure (binary cannot be started at all), distinct from the non-zero exit code case which is reported separately above it. Typical cause: the command's binary does not exist or is not executable.","triggerScenarios":"beforeDevCommand set to a package-manager script before dependencies are installed (no node_modules/.bin), referencing a tool that is not on PATH (`vite`, `yarn`, `pnpm`), or a command string whose binary cannot be resolved by the OS.","commonSituations":"Fresh clone without `npm install`; switching package managers (pnpm-lock but command says yarn); CI images missing Node tooling; Windows needing `.cmd` resolution through `npm run` rather than the raw binary.","solutions":["Run the exact beforeDevCommand manually in the frontend directory; install what it complains about (`npm install`, `corepack enable`)","Prefer package-runner form like `npm run dev` / `pnpm dev` instead of raw binary names so local node_modules/.bin is used","Fix or clear build > beforeDevCommand in tauri.conf.json if the frontend needs no dev server step"],"exampleFix":"// before (tauri.conf.json)\n\"build\": { \"beforeDevCommand\": \"vite\", \"devUrl\": \"http://localhost:5173\" }\n\n// after\n\"build\": { \"beforeDevCommand\": \"npm run dev\", \"devUrl\": \"http://localhost:5173\" }","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# verify the beforeDevCommand binary resolves before starting tauri dev\ncmd=$(jq -r '.build.beforeDevCommand // \"\"' src-tauri/tauri.conf.json | awk '{print $1}')\n[ -z \"$cmd\" ] || command -v \"$cmd\" >/dev/null || { echo \"beforeDevCommand binary '$cmd' not found; run npm install\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer `npm run <script>` / `pnpm <script>` forms for beforeDevCommand so local binaries resolve","Run npm install (or your package manager's install) as the first CI step","Smoke-test beforeDevCommand manually in the frontend dir whenever package.json changes"],"tags":["tauri-cli","dev","before-dev-command","spawn","command-not-found"],"backgroundTag":"command-not-found","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}