jdx/mise · error

sudo requires a password but no TTY is available. Run…

Error message

sudo requires a password but no TTY is available. Run manually:
  {manual_cmd}

What it means

When stderr is not a TTY, sudo cannot prompt for a password, so ensure_elevation_available first probes with `sudo -v` (output discarded). If that probe fails — meaning sudo needs a password but there is no terminal to type it into — mise bails with this message and the manual command. This prevents silently hanging or failing midway through an elevated operation in non-interactive contexts.

Solutions

  1. Run the printed manual command in an interactive shell first (or `sudo -v`) to cache credentials, then retry
  2. Configure passwordless sudo for the user (NOPASSWD in sudoers) for the relevant commands
  3. Run mise as root (e.g. in CI run the step as root user)
  4. Ensure the command runs with a TTY (ssh -t, script -c, CI pseudo-terminal) if interactive sudo is acceptable

Example fix

// before (CI yaml, no TTY, expired creds)
- run: mise install
// after
- run: sudo -v || true && sudo -n true && mise install   # or grant NOPASSWD in sudoers
Defensive patterns

Strategy: fallback

Validate before calling

// probe non-interactive sudo before automation
std::process::Command::new("sudo")
    .arg("-n").arg("true")
    .status()
    .map(|s| s.success())
    .unwrap_or(false);

Prevention

When it happens

Trigger: Running an elevated operation (run/run_in_dir/output/run_with_input/run_with_input_output) as non-root with sudo enabled and present, but stderr is redirected (CI logs, pipes, scripts) and cached sudo credentials have expired so the `sudo -v` probe fails.

Common situations: CI/CD pipelines invoking mise system-package installs without passwordless sudo; running under cron/IDE terminals without TTY; SSH command execution without -t; long sessions where the sudo timestamp timed out.

Related errors


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

Appendix: source

Thrown at src/system/sudo.rs:304

        );
    }
    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}"
            );
        }
    }
    Ok(())
}

#[cfg(test)]
mod tests {
    use super::*;

    /// Each elevated helper binds the guard for the rest of its body, so the
    /// renderer stays suspended until the child exits rather than only while
    /// the guard is constructed. Nested acquisitions — a `with_sudo_fallback`
    /// retry inside a flight step — must not resume it early either.
    #[test]
    fn pause_progress_for_child_suspends_until_every_guard_drops() {
        let report = MultiProgressReport::get();

View on GitHub (pinned to 533346cc37)