{"record":{"id":"8e0f38111830f11e","repo":"sxyazi/yazi","slug":"cmd-exited-with-status-status","errorCode":null,"errorMessage":"{cmd:?} exited with status {status}","messagePattern":"(.+?) exited with status (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-build/src/common.rs","lineNumber":69,"sourceCode":"\tlet ext = if is_windows_target(target) { \".exe\" } else { \"\" };\n\tcopy_file(&from.join(format!(\"yazi{ext}\")), &to.join(format!(\"yazi{ext}\")))?;\n\tcopy_file(&from.join(format!(\"ya{ext}\")), &to.join(format!(\"ya{ext}\")))?;\n\tOk(())\n}\n\npub(super) fn copy_file(from: &Path, to: &Path) -> Result<()> {\n\tfs::copy(from, to)\n\t\t.map(|_| ())\n\t\t.with_context(|| format!(\"failed to copy {} to {}\", from.display(), to.display()))\n}\n\npub(super) fn run(cmd: &mut Command) -> Result<()> {\n\tlet status = cmd\n\t\t.current_dir(workspace_root()?)\n\t\t.status()\n\t\t.with_context(|| format!(\"failed to spawn {cmd:?}\"))?;\n\n\tensure!(status.success(), \"{cmd:?} exited with status {status}\");\n\tOk(())\n}\n","sourceCodeStart":51,"sourceCodeEnd":72,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-build/src/common.rs#L51-L72","documentation":"Generic wrapper for external commands spawned by `yazi-build` (cargo builds, etc.). `run()` executes the command with the workspace root as cwd; if the child process exits with a non-zero status, the `ensure!` fails with the command's debug representation and its exit status. The command spawned fine (spawn failures get a different context message) — the program itself failed.","triggerScenarios":"Any `yazi-build` step invoking cargo or another tool that exits non-zero: compile errors during `ya build`/`ya dist`, `cargo build --locked` failing due to a Cargo.lock mismatch, the release config `.cargo/release.toml` being invalid, linker failures, or a custom `RUSTC`/`CARGO` binary failing.","commonSituations":"Missing target triple (target not installed via rustup); Cargo.lock out of date after editing Cargo.toml; compile error in the workspace; missing system linker for cross-compilation.","solutions":["Read the compiler/cargo output printed above the error for the real failure","Install the target toolchain with `rustup target add <triple>` if the target is missing","Run `cargo update` or restore Cargo.lock if `--locked` reports a lockfile mismatch","Run the failing cargo command manually from the workspace root to reproduce and fix compile/link errors"],"exampleFix":"// before (lockfile out of sync with Cargo.toml)\nerror: \"cargo\" \"--config\" \".cargo/release.toml\" \"build\" \"--locked\" ... exited with status exit status: 101\n\n// after\n$ cargo update -p yazi-fm   # or remove --locked inconsistency\n$ ya build","handlingStrategy":"try-catch","validationCode":"# preflight checks before running ya build/dist\ncargo --version && rustc --version\nrustup target list --installed | grep -q <triple> || rustup target add <triple>\n# ensure Cargo.lock is in sync\ncargo metadata --locked --format-version 1 >/dev/null || cargo update --locked","typeGuard":null,"tryCatchPattern":"try {\n  execSync('ya build --target ' + triple, { stdio: 'inherit' });\n} catch (err) {\n  // the real cause is in the child's stderr printed above this error\n  console.error('Build step failed; inspect cargo/compiler output above');\n  throw err;\n}","preventionTips":["Always read the child-process output printed before this error — it names the real failure","Keep Cargo.lock committed and in sync with Cargo.toml edits","Install target toolchains (rustup target add) before cross-building","Run the failing cargo command manually from the workspace root to iterate on fixes"],"tags":["subprocess","cargo","build-tooling"],"backgroundTag":"subprocess-nonzero-exit","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}