jdx/mise · error
sudo not found. Run as root
Error message
sudo not found. Run as root:
{} What it means
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.
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
Example fix
# before $ mise use system-packages:ripgrep Error: sudo not found. Run as root: apt-get install -y ripgrep # after $ sudo apt-get install -y ripgrep # or: apt-get install sudo first
Defensive patterns
Strategy: validation
Validate before calling
if !nix::unistd::Uid::effective().is_root()
&& which::which("sudo").is_err() {
eprintln!("sudo missing on PATH; install it or run the command as root");
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- elevated bootstrap helper failed with
- elevated bootstrap helper failed with
- failed
- is not available: required binary ' ' not found; add it to…
- not running as root and system_packages.sudo is disabled…
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/783ebbacba4fefd5.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/sudo.rs:289
if !output.status.success() {
bail!("elevated bootstrap helper failed with {}", output.status);
}
Ok(output.stdout)
}
/// Verify that a subprocess which performs its own sudo elevation can do so
/// without violating mise's elevation policy or hanging without a TTY.
pub(crate) fn ensure_elevation_available(manual_cmd: &str) -> Result<()> {
if is_root() {
return Ok(());
}
if !Settings::get().system_packages.sudo {
bail!(
"not running as root and system_packages.sudo is disabled. Run manually:\n {manual_cmd}"
);
}
if crate::file::which("sudo").is_none() {
bail!(
"sudo not found. Run as root:\n {}",
manual_cmd.trim_start_matches("sudo ")
);
}
if !console::user_attended_stderr() {
let ok = Command::new("sudo")
.args(["-n", "true"])
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
.map(|status| status.success())
.unwrap_or(false);
if !ok {
bail!(
"sudo requires a password but no TTY is available. Run manually:\n {manual_cmd}"
);
}View on GitHub (pinned to 533346cc37)