{"record":{"id":"38de5d60ba30be4c","repo":"jdx/mise","slug":"aur-packages-cannot-be-built-as-root-run-mise-as","errorCode":null,"errorMessage":"AUR packages cannot be built as root; run mise as a non-root user","messagePattern":"AUR packages cannot be built as root; run mise as a non-root user","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/aur.rs","lineNumber":194,"sourceCode":"    }\n\n    async fn install(&self, pkgs: &[PackageRequest], opts: &InstallOpts) -> Result<()> {\n        if let Some(pkg) = pkgs.iter().find(|pkg| pkg.version.is_some()) {\n            bail!(\"AUR helpers cannot install a pinned version ('{pkg}')\");\n        }\n        let helper = self\n            .helper()\n            .ok_or_else(|| eyre::eyre!(self.unavailable_reason()))?;\n        let args = install_args(pkgs, opts);\n        let command = std::iter::once(helper.to_string())\n            .chain(args.iter().cloned())\n            .collect::<Vec<_>>();\n        if opts.dry_run {\n            miseprintln!(\"{}\", shell_words::join(command));\n            return Ok(());\n        }\n        if crate::system::sudo::is_root() {\n            bail!(\"AUR packages cannot be built as root; run mise as a non-root user\");\n        }\n        crate::system::sudo::ensure_elevation_available(&shell_words::join(&command))?;\n        let mut runner = CmdLineRunner::new(helper);\n        for arg in &args {\n            runner = runner.arg(arg);\n        }\n        runner.raw(true).execute()\n    }\n\n    async fn upgrade(&self, pkgs: &[PackageRequest], opts: &InstallOpts) -> Result<()> {\n        let pkgs = resolve_foreign_packages(pkgs)\n            .await?\n            .into_iter()\n            .filter_map(|package| {\n                package.installed_name.map(|name| PackageRequest {\n                    name,\n                    version: None,\n                    tap_url: None,","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/aur.rs#L176-L212","documentation":"AUR helpers must build packages with makepkg, which refuses to run as root; AurManager::install() therefore bails when `crate::system::sudo::is_root()` is true and the run is not a dry-run. This happens before elevation checks and helper invocation, because building AUR packages as root is unsupported and dangerous.","triggerScenarios":"Running mise as root (root shell, sudo mise, sudo su, container/CI defaulting to root) and executing `mise install`/`mise upgrade` for any `aur:` package (non-dry-run) — the install path checks is_root() and bails.","commonSituations":"CI containers running as root, SSH-ing directly as root on an Arch box, bootstrapping dotfiles with `sudo mise`, or a provisioning script that runs everything under sudo.","solutions":["Run mise as a normal (non-root) user; mise will invoke the helper, which elevates only the pacman transaction via sudo.","In containers/CI, create a build user (`useradd -m builder && su builder`) and run `mise install` as that user, giving it passwordless sudo for pacman if needed.","Avoid `sudo mise install` / `sudo -i` workflows for AUR packages entirely; use mise's own elevation handling instead.","If only probing, use --dry-run, which returns before the root check."],"exampleFix":"// before: root shell in CI\n# mise install aur:yay\nError: AUR packages cannot be built as root; run mise as a non-root user\n\n// after\n# useradd -m builder && sudo -u builder mise install aur:yay","handlingStrategy":"validation","validationCode":"// check before running mise AUR installs in scripts/CI\nimport { userInfo } from 'node:os';\nif (userInfo().uid === 0) {\n  throw new Error('Refusing to run mise AUR installs as root; switch to a non-root user with sudo access');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await mise.install('aur:yay');\n} catch (err) {\n  if (err instanceof Error && err.message.includes('cannot be built as root')) {\n    // drop privileges and retry as the build user\n    await run('sudo', ['-u', 'builder', 'mise', 'install', 'aur:yay']);\n  } else throw err;\n}","preventionTips":["Never run `sudo mise install/upgrade` for aur: packages; mise handles elevation itself.","In containers/CI that default to root, create and switch to an unprivileged build user before installing AUR tools.","Make the root check part of your provisioning scripts: bail early if `id -u` is 0 and AUR tools are in the tool list.","Give the build user targeted passwordless sudo (pacman only) so the helper can complete its transaction."],"tags":["aur","arch-linux","root","permissions","package-manager"],"backgroundTag":"permission-denied","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}