{"record":{"id":"ce577c449ac6ec76","repo":"gitbutlerapp/gitbutler","slug":"command-exited-with-status","errorCode":null,"errorMessage":"command exited with status {}","messagePattern":"command exited with status (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/status/tui/app/command_mode.rs","lineNumber":240,"sourceCode":"                    return Ok(());\n                } else {\n                    return Err(err).context(\"failed to start command\");\n                }\n            }\n        };\n        let status = child.wait()?;\n\n        if !IN_TEST {\n            out.prompt_single_line(\"\\npress enter to continue...\")?;\n        }\n\n        if status.success() {\n            messages.extend([\n                Message::EnterNormalModeAfterConfirmingOperation,\n                Message::Reload(None, ReloadCause::Mutation),\n            ]);\n        } else {\n            self.push_transient_error(anyhow!(\n                \"command exited with status {}\",\n                format_exit_status(status)\n            ));\n        }\n\n        drop(_suspend_guard);\n\n        Ok(())\n    }\n}\n\n/// Formats an exit status for human-readable error messages.\nfn format_exit_status(status: std::process::ExitStatus) -> String {\n    if let Some(code) = status.code() {\n        code.to_string()\n    } else {\n        status.to_string()\n    }","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/status/tui/app/command_mode.rs#L222-L258","documentation":"Thrown by the `but` TUI command mode after it spawns a user-requested shell command as a child process and that process exits with a non-zero status. The exit status is formatted (exit code and/or signal) and shown as a transient error in the TUI. It is the child command's own failure propagated into but, not a bug in but itself.","triggerScenarios":"Entering command mode in the but TUI and running a command that fails: the binary is missing (shell exit 127), a git/build/test subcommand returns non-zero, or the process is killed by a signal.","commonSituations":"Running tests or git commands from the TUI on a failing tree; typos in the command; PATH differences between the interactive shell and the environment but was started in.","solutions":["Run the exact same command in a regular shell to see its real stdout/stderr and exit code","Fix the command itself (binary name, arguments, required env vars) and rerun it from command mode","Interpret the status: 127 = command not found, 126 = not executable, >= 128 = terminated by signal","If the tool is not found, start but from a shell whose PATH includes it"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"use which::which;\n\nlet (prog, _args) = split_cmd_word(&cmd_line);\nif which(prog).is_err() {\n    return Err(anyhow!(\"'{prog}' not found on PATH\"));\n}","typeGuard":null,"tryCatchPattern":"Spawn with .output() instead of .wait() so the child's stderr is captured; match on the exit status and include stderr plus the numeric code in the transient error, mapping 127 to a dedicated 'command not found' hint.","preventionTips":["Verify a command works in an interactive shell before running it from the TUI","Capture child stderr so failures are diagnosable","Start but from a shell with the same PATH your commands need"],"tags":["tui","process","exit-code","shell"],"backgroundTag":"command-exit-non-zero","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}