{"record":{"id":"783ebbacba4fefd5","repo":"jdx/mise","slug":"sudo-not-found-run-as-root","errorCode":null,"errorMessage":"sudo not found. Run as root:\n  {}","messagePattern":"sudo not found\\. Run as root:\n  (.+?)","errorType":"exception","errorClass":"eyre::Report","httpStatus":null,"severity":"error","filePath":"src/system/sudo.rs","lineNumber":261,"sourceCode":"        .write_all(input)?;\n    let output = child.wait_with_output()?;\n    if !output.status.success() {\n        bail!(\"elevated bootstrap helper failed with {}\", output.status);\n    }\n    Ok(output.stdout)\n}\n\nfn ensure_elevation_available(manual_cmd: &str) -> Result<()> {\n    if is_root() {\n        return Ok(());\n    }\n    if !Settings::get().system_packages.sudo {\n        bail!(\n            \"not running as root and system_packages.sudo is disabled. Run manually:\\n  {manual_cmd}\"\n        );\n    }\n    if crate::file::which(\"sudo\").is_none() {\n        bail!(\n            \"sudo not found. Run as root:\\n  {}\",\n            manual_cmd.trim_start_matches(\"sudo \")\n        );\n    }\n    if !console::user_attended_stderr() {\n        let ok = Command::new(\"sudo\")\n            .args([\"-n\", \"true\"])\n            .stdin(Stdio::null())\n            .stdout(Stdio::null())\n            .stderr(Stdio::null())\n            .status()\n            .map(|status| status.success())\n            .unwrap_or(false);\n        if !ok {\n            bail!(\n                \"sudo requires a password but no TTY is available. Run manually:\\n  {manual_cmd}\"\n            );\n        }","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/jdx/mise/blob/9dcfcaa0dc8747a2577d3270b69bb9d8313b2807/src/system/sudo.rs#L243-L279","documentation":"ensure_elevation_available needs sudo (not root, elevation enabled) but crate::file::which(\"sudo\") found no sudo binary on PATH. The error strips the leading 'sudo ' from the manual command and instructs the user to run the remainder as root directly.","triggerScenarios":"The elevation preconditions are checked in order: is_root() false, system_packages.sudo true, then which(\"sudo\") returns None - typical of minimal container images or a broken PATH.","commonSituations":"debian:slim or distroless Docker images without sudo installed; chroot/scratch environments; PATH not including /usr/bin; unprivileged CI users in images that only ship su.","solutions":["Install sudo in the environment (apt-get install sudo / dnf install sudo / apk add sudo)","Run mise as root so elevation is unnecessary, or use su: `su -c '<manual command minus sudo prefix>'`","Verify PATH resolution with `which sudo` in the same shell/environment mise runs in"],"exampleFix":"# Dockerfile (before)\nFROM debian:slim\nRUN mise install -y system\n\n# after\nFROM debian:slim\nRUN apt-get update && apt-get install -y sudo","handlingStrategy":"validation","validationCode":"use std::process::Command;\nfn sudo_present() -> bool {\n    // mirror mise's own check: is sudo resolvable on PATH?\n    Command::new(\"sh\").arg(\"-c\").arg(\"command -v sudo\").status().map(|s| s.success()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install sudo in base images that will run mise as non-root","Assert `command -v sudo` in CI setup scripts before any mise system-packages step","If sudo is intentionally absent, run mise as root so the check never runs"],"tags":["sudo","path","container","privileges","missing-binary"],"backgroundTag":"command-not-found","analyzedSha":"9dcfcaa0dc8747a2577d3270b69bb9d8313b2807","analyzedAt":"2026-08-17T14:28:50.624Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}