tauri-apps/tauri · error
failed to run `{before_dev}`
Error message
failed to run `{before_dev}` What it means
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.
Source
Thrown at crates/tauri-cli/src/dev.rs:207
"`{before_dev}` with `{}`",
if cfg!(windows) { "cmd /S /C" } else { "sh -c" }
),
error,
})?;
if !status.success() {
crate::error::bail!(
"beforeDevCommand `{}` failed with exit code {}",
before_dev,
status.code().unwrap_or_default()
);
}
} else {
command.stdin(Stdio::piped());
command.stdout(os_pipe::dup_stdout().unwrap());
command.stderr(os_pipe::dup_stderr().unwrap());
let child = SharedChild::spawn(&mut command)
.unwrap_or_else(|_| panic!("failed to run `{before_dev}`"));
let child = BEFORE_DEV.get_or_init(move || child);
std::thread::spawn(move || {
let status = child
.wait()
.expect("failed to wait on \"beforeDevCommand\"");
if !(status.success() || KILL_BEFORE_DEV_FLAG.load(Ordering::SeqCst)) {
log::error!("The \"beforeDevCommand\" terminated with a non-zero status code.");
exit(status.code().unwrap_or(1));
}
});
let _ = ctrlc::set_handler(move || {
kill_before_dev_process();
exit(130);
});
}
}View on GitHub (pinned to 52e4b6e71d)
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
Example fix
// before (tauri.conf.json)
"build": { "beforeDevCommand": "vite", "devUrl": "http://localhost:5173" }
// after
"build": { "beforeDevCommand": "npm run dev", "devUrl": "http://localhost:5173" } Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash
# verify the beforeDevCommand binary resolves before starting tauri dev
cmd=$(jq -r '.build.beforeDevCommand // ""' src-tauri/tauri.conf.json | awk '{print $1}')
[ -z "$cmd" ] || command -v "$cmd" >/dev/null || { echo "beforeDevCommand binary '$cmd' not found; run npm install"; exit 1; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- beforeDevCommand `{}` failed with exit code {}
- invalid permission {p}
- Couldn't recognize the {} folder as a Tauri project. It must
- No external IP detected.
- failed to read missing addr file {}: {e}
AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20).
Data as JSON: /api/errors/238ffa9d2bb42cda.
Report an issue: GitHub.