jdx/mise · error

not running as root and system_packages.sudo is disabled…

Error message

not running as root and system_packages.sudo is disabled. Run manually:
  {manual_cmd}

What it means

ensure_elevation_available gates every elevated operation in sudo.rs (run, run_in_dir, output, run_with_input, run_with_input_output). If the process is not root and the system_packages.sudo setting is disabled, mise refuses to elevate and prints the equivalent manual command the user can run themselves. This is deliberate policy: mise will never invoke sudo unless explicitly enabled.

Solutions

  1. Run the printed manual command yourself in a root shell (the message includes the exact command)
  2. Enable the setting: add [system_packages] sudo = true to mise.toml (or MISE_SYSTEM_PACKAGES_SUDO=1)
  3. Run mise as root if elevation is acceptable in your environment
  4. Install the packages outside mise (system package manager directly) and skip the mise system-packages step

Example fix

# before (mise.toml)
[tools]
node = "22"
# after
[tools]
node = "22"

[system_packages]
sudo = true
Defensive patterns

Strategy: validation

Validate before calling

// caller pre-check mirroring ensure_elevation_available
if !nix::unistd::Uid::effective().is_root()
    && !Settings::get().system_packages.sudo {
    eprintln!("elevation disabled; run the manual command yourself");
}

Prevention

When it happens

Trigger: Any system-package operation requiring root while: (1) effective uid != 0 and (2) Settings system_packages.sudo is false (the default / not enabled in mise.toml).

Common situations: Running `mise use -g system-packages ...` or installing system packages as a normal user with sudo support never enabled; CI containers running non-root where users expect automatic elevation; upgrading mise and encountering the new system_packages feature unaware.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/544b7cf4081ad613. Report an issue: GitHub.

Appendix: source

Thrown at src/system/sudo.rs:284

        .stdin
        .take()
        .expect("piped stdin is available")
        .write_all(input)?;
    let output = child.wait_with_output()?;
    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);

View on GitHub (pinned to 533346cc37)