{"record":{"id":"544b7cf4081ad613","repo":"jdx/mise","slug":"not-running-as-root-and-system-packages-sudo-is-di","errorCode":null,"errorMessage":"not running as root and system_packages.sudo is disabled. Run manually:\n  {manual_cmd}","messagePattern":"not running as root and system_packages\\.sudo is disabled\\. Run manually:\n  (.+?)","errorType":"exception","errorClass":"eyre::Report","httpStatus":null,"severity":"error","filePath":"src/system/sudo.rs","lineNumber":256,"sourceCode":"        .spawn()?;\n    child\n        .stdin\n        .take()\n        .expect(\"piped stdin is available\")\n        .write_all(input)?;\n    let output = child.wait_with_output()?;\n    if !output.status.success() {\n        bail!(\"elevated bootstrap helper failed with {}\", output.status);\n    }\n    Ok(output.stdout)\n}\n\nfn 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);","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/jdx/mise/blob/9dcfcaa0dc8747a2577d3270b69bb9d8313b2807/src/system/sudo.rs#L238-L274","documentation":"Raised by ensure_elevation_available when an operation requires root privileges, mise is not running as root, and the user has explicitly disabled sudo elevation via the system_packages.sudo setting. Instead of attempting elevation, mise refuses and embeds the exact manual command (manual_cmd) the user can copy-paste to perform the step themselves.","triggerScenarios":"A system-packages/bootstrap operation that needs privilege while Settings::get().system_packages.sudo is false and euid != 0; the code path is reached from any privileged install/ensure step.","commonSituations":"Hardened setups where users opted out of mise ever invoking sudo, then run a bootstrap that installs system packages; shared machines where sudo is policy-restricted.","solutions":["Run the manual command printed in the error message verbatim - it is the exact command mise would have executed via sudo","Re-enable elevation with `system_packages.sudo = true` in settings.toml (or the corresponding env var) and retry","Run mise itself as root (container/CI image) so the is_root() short-circuit passes"],"exampleFix":"# ~/.config/mise/settings.toml (before)\n[system_packages]\nsudo = false\n\n# after - allow mise to elevate via sudo\n[system_packages]\nsudo = true","handlingStrategy":"validation","validationCode":"# shell: gate the privileged step explicitly\nif [ \"$(id -u)\" -ne 0 ] && ! grep -q '^sudo = true' ~/.config/mise/settings.toml 2>/dev/null; then\n  echo \"run as root, enable system_packages.sudo, or execute the manual command mise prints\"\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document the exact manual bootstrap command so users who disable system_packages.sudo can run it themselves","Decide a policy once (root container vs NOPASSWD sudo vs manual) and encode it in settings.toml per environment","In Dockerfiles, prefer running mise bootstrap as root so is_root() short-circuits the check"],"tags":["sudo","settings","privileges","system-packages","configuration"],"backgroundTag":"privilege-required","analyzedSha":"9dcfcaa0dc8747a2577d3270b69bb9d8313b2807","analyzedAt":"2026-08-17T14:28:50.624Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}