{"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":null,"httpStatus":null,"severity":"error","filePath":"src/system/sudo.rs","lineNumber":284,"sourceCode":"        .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\n/// Verify that a subprocess which performs its own sudo elevation can do so\n/// without violating mise's elevation policy or hanging without a TTY.\npub(crate) fn 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":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/sudo.rs#L266-L302","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Run the printed manual command yourself in a root shell (the message includes the exact command)","Enable the setting: add [system_packages] sudo = true to mise.toml (or MISE_SYSTEM_PACKAGES_SUDO=1)","Run mise as root if elevation is acceptable in your environment","Install the packages outside mise (system package manager directly) and skip the mise system-packages step"],"exampleFix":"# before (mise.toml)\n[tools]\nnode = \"22\"\n# after\n[tools]\nnode = \"22\"\n\n[system_packages]\nsudo = true","handlingStrategy":"validation","validationCode":"// caller pre-check mirroring ensure_elevation_available\nif !nix::unistd::Uid::effective().is_root()\n    && !Settings::get().system_packages.sudo {\n    eprintln!(\"elevation disabled; run the manual command yourself\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable [system_packages] sudo = true in mise.toml if you want mise to elevate for system packages","In CI, run steps as root or pre-install packages outside mise","Read the manual command in the error message — it is the exact equivalent you can run yourself"],"tags":["sudo","elevation","permissions","config"],"backgroundTag":"permission-denied","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}