{"record":{"id":"f48d613999810b81","repo":"nikivdev/code","slug":"recipe-failed-with-status","errorCode":null,"errorMessage":"recipe '{}' failed with status {}","messagePattern":"recipe '(.+?)' failed with status (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/recipe.rs","lineNumber":158,"sourceCode":"            let shell_bin = resolve_shell_bin(shell);\n            let shell_cmd = command.trim();\n            println!(\"engine: shell\");\n            println!(\"shell: {}\", shell_bin);\n            println!(\"cmd: {}\", shell_cmd);\n\n            if opts.dry_run {\n                return Ok(());\n            }\n\n            let status = Command::new(&shell_bin)\n                .arg(\"-lc\")\n                .arg(shell_cmd)\n                .current_dir(&cwd)\n                .status()\n                .with_context(|| format!(\"failed to run recipe command via {}\", shell_bin))?;\n\n            if !status.success() {\n                bail!(\"recipe '{}' failed with status {}\", recipe.id, status);\n            }\n        }\n        RecipeRunner::MoonbitFile => {\n            println!(\"engine: moonbit\");\n            println!(\"cmd: moon run {}\", recipe.path.display());\n\n            if opts.dry_run {\n                return Ok(());\n            }\n\n            let status = Command::new(\"moon\")\n                .arg(\"run\")\n                .arg(&recipe.path)\n                .current_dir(&cwd)\n                .status()\n                .with_context(|| format!(\"failed to run moon recipe {}\", recipe.path.display()))?;\n\n            if !status.success() {","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/recipe.rs#L140-L176","documentation":"`run_recipe` bails when a shell-based recipe (`RecipeRunner` shell variant) finishes with a non-zero exit status. The error is intentional pass-through of the recipe's own failure so the CLI exit code reflects the script's outcome.","triggerScenarios":"Running a recipe whose shell command (executed via the configured shell_bin with cwd = resolved working dir) exits non-zero: build failures, failing tests, missing binaries inside the script, script syntax errors.","commonSituations":"Recipe scripts assuming tools that aren't installed or not on PATH; running the recipe from the wrong working directory so relative paths break; test/lint failures in the underlying project; shell differences (script written for bash run under sh).","solutions":["Read the script output printed just before the error to see the underlying failure and fix it","Run the recipe's command manually in the same cwd to reproduce and debug","Install or PATH-enable the tools the recipe script depends on","Pass/verify the correct cwd when invoking run_recipe so relative paths resolve","Set the recipe to use an explicit shell (e.g. bash) if it uses bash-only syntax"],"exampleFix":"// before: recipe command `npm test` fails\nError: recipe 'ci-checks' failed with status exit status: 1\n// after\n$ npm test   # run manually; a test in src/app.spec.ts fails\n$ fix test... && f recipe run ci-checks","handlingStrategy":"try-catch","validationCode":"// preflight: verify the underlying command works before running the recipe\n// (adjust to the recipe's command)\nif !std::process::Command::new(\"npm\").arg(\"--version\").status().map_or(false, |s| s.success()) {\n    eprintln!(\"npm not available; recipe will fail\");\n}","typeGuard":null,"tryCatchPattern":"match run_recipe(opts) {\n    Ok(()) => {},\n    Err(e) if e.to_string().contains(\"failed with status\") => {\n        eprintln!(\"recipe script failed; read its output above and fix the underlying command\");\n        std::process::exit(1); // preserve failure semantics\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Run recipe scripts manually once before wiring them into automation","Ensure all tools the script uses are installed and on PATH","Verify the recipe's working directory (cwd) contains the files it expects","Pin the shell in the recipe (bash vs sh) to avoid syntax surprises"],"tags":["subprocess","exit-status","recipes","shell"],"backgroundTag":"recipe-command-exit-nonzero","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}