{"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":null,"httpStatus":null,"severity":"error","filePath":"src/system/sudo.rs","lineNumber":289,"sourceCode":"    if !output.status.success() {\n        bail!(\"elevated bootstrap helper failed with {}\", output.status);\n    }\n    Ok(output.stdout)\n}\n\n/// Verify that a subprocess which performs its own sudo elevation can do so\n/// without violating mise's elevation policy or hanging without a TTY.\npub(crate) fn 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":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/sudo.rs#L271-L307","documentation":"ensure_elevation_available requires the `sudo` binary when elevating. If the process is not root, system_packages.sudo is enabled, but `crate::file::which(\"sudo\")` finds nothing on PATH, mise bails and prints the manual command with the leading 'sudo ' stripped so it can be run directly as root.","triggerScenarios":"Any elevated sudo.rs operation (run, run_in_dir, output, run_with_input, run_with_input_output) where the user is non-root, system_packages.sudo is true, but no `sudo` executable exists on PATH.","commonSituations":"Minimal container images (distroless, slim Docker images) without sudo installed; Windows/WSL setups where sudo is absent; sudo removed from PATH inside mise's isolated exec environment (env -i, stripped PATH in hooks).","solutions":["Install sudo (apt-get install sudo / dnf install sudo) or add it to PATH","Run the printed manual command directly as root (it already has 'sudo ' stripped)","Execute mise as root so no sudo binary is needed","If elevation is not desired, disable system_packages.sudo and run commands manually"],"exampleFix":"# before\n$ mise use system-packages:ripgrep\nError: sudo not found. Run as root:\n  apt-get install -y ripgrep\n# after\n$ sudo apt-get install -y ripgrep   # or: apt-get install sudo first","handlingStrategy":"validation","validationCode":"if !nix::unistd::Uid::effective().is_root()\n    && which::which(\"sudo\").is_err() {\n    eprintln!(\"sudo missing on PATH; install it or run the command as root\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install sudo in container images that run mise system-package operations","Do not strip /usr/bin:/usr/sbin or the sudo path from PATH in exec environments","Prefer running as root in minimal images instead of relying on sudo"],"tags":["sudo","missing-binary","path","elevation"],"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"}