jdx/mise · error · eyre::Report

sudo not found. Run as root: {}

Error message

sudo not found. Run as root:
  {}

What it means

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.

Source

Thrown at src/system/sudo.rs:261

        .write_all(input)?;
    let output = child.wait_with_output()?;
    if !output.status.success() {
        bail!("elevated bootstrap helper failed with {}", output.status);
    }
    Ok(output.stdout)
}

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 9dcfcaa0dc)

Solutions

  1. Install sudo in the environment (apt-get install sudo / dnf install sudo / apk add sudo)
  2. Run mise as root so elevation is unnecessary, or use su: `su -c '<manual command minus sudo prefix>'`
  3. Verify PATH resolution with `which sudo` in the same shell/environment mise runs in

Example fix

# Dockerfile (before)
FROM debian:slim
RUN mise install -y system

# after
FROM debian:slim
RUN apt-get update && apt-get install -y sudo
Defensive patterns

Strategy: validation

Validate before calling

use std::process::Command;
fn sudo_present() -> bool {
    // mirror mise's own check: is sudo resolvable on PATH?
    Command::new("sh").arg("-c").arg("command -v sudo").status().map(|s| s.success()).unwrap_or(false)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jdx/mise@9dcfcaa0dc (2026-08-17). Data as JSON: /api/errors/783ebbacba4fefd5. Report an issue: GitHub.