{"record":{"id":"7cb5cd267089553c","repo":"jdx/mise","slug":"program-failed-with-status","errorCode":null,"errorMessage":"{program} failed with {status}","messagePattern":"(.+?) failed with (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/accounts.rs","lineNumber":1013,"sourceCode":"                    args.push(\"--remove\".to_string());\n                }\n                args.push(name);\n                run_account_command(\"userdel\", &args)\n            }\n        }\n    }\n}\n\nfn run_account_command(program: &str, args: &[String]) -> Result<()> {\n    let path = [\"/usr/sbin\", \"/usr/bin\", \"/sbin\", \"/bin\"]\n        .iter()\n        .map(|dir| PathBuf::from(dir).join(program))\n        .find(|path| path.is_file())\n        .ok_or_else(|| eyre!(\"required account command '{program}' was not found\"))?;\n    info!(\"$ {} {}\", path.display(), args.join(\" \"));\n    let status = Command::new(&path).args(args).status()?;\n    if !status.success() {\n        bail!(\"{program} failed with {status}\");\n    }\n    Ok(())\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn validates_account_names() {\n        assert!(validate_name(\"user\", \"mise-cache_1\").is_ok());\n        assert!(validate_name(\"user\", \"1invalid\").is_err());\n        assert!(validate_name(\"user\", \"-invalid\").is_err());\n        assert!(validate_name(\"group\", \"invalid/name\").is_err());\n        assert!(validate_name(\"group\", &\"a\".repeat(33)).is_err());\n    }\n\n    #[test]","sourceCodeStart":995,"sourceCodeEnd":1031,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/accounts.rs#L995-L1031","documentation":"This error is raised by the account command runner in src/system/accounts.rs when an external command required to manage users/groups (e.g. useradd, groupadd, usermod) exits with a non-zero status. The runner locates the program on PATH, executes it, and translates any failure exit code into this error including the program name and its exit Status. It wraps all failures of the privileged account tooling into one message.","triggerScenarios":"Running bootstrap user/group apply where the invoked account command (useradd/groupadd/etc.) returns non-zero — e.g. group already exists, invalid option values, insufficient privileges, or the backend rejecting a username.","commonSituations":"Applying a bootstrap plan where the group or user already exists with conflicting attributes; running without root so the account command is denied; a config-derived group name violating system constraints; partial prior apply leaving inconsistent state.","solutions":["Read the full stderr from the failed command (run with debug logging: MISE_DEBUG=1) to see the account tool's actual complaint.","Ensure the apply step runs as root (sudo) so account tools can modify /etc/passwd and /etc/group.","Make the plan idempotent or reconcile pre-existing users/groups with the same GID/UID before applying.","Fix the offending group/user definition in the [bootstrap] config (invalid names, duplicate GIDs, bad home dirs)."],"exampleFix":"// before\nsudo mise bootstrap apply   # fails: useradd failed with exit status 9 (user exists)\n// after\n# either remove the existing conflicting user or align the plan\nsudo usermod -g developers deploy && sudo mise bootstrap apply","handlingStrategy":"try-catch","validationCode":"for prog in [\"useradd\", \"groupadd\"] {\n    if which(prog).is_none() {\n        return Err(format!(\"required account command '{prog}' was not found\"));\n    }\n}\nif !nix::unistd::Uid::effective().is_root() {\n    return Err(\"account commands require root\".into());\n}","typeGuard":"fn ran_successfully(status: &std::process::ExitStatus) -> bool { status.success() }","tryCatchPattern":"match run_account_program(\"useradd\", &args) {\n    Err(e) if e.to_string().contains(\"failed with\") => {\n        // capture stderr, check for 'already exists' / permission denied and reconcile\n        eprintln!(\"account command failed: {e}\");\n    }\n    Err(e) => return Err(e),\n    Ok(()) => {}\n}","preventionTips":["Run bootstrap apply as root (sudo)","Make plans idempotent: check for existing users/groups before adding","Run with MISE_DEBUG=1 to capture the underlying command output","Validate group names/GIDs/UIDs against system constraints before applying"],"tags":["subprocess","command","accounts","bootstrap","linux"],"backgroundTag":"command-not-found","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}