Morganamilo/paru · error
can't install AUR package as root
Error message
can't install AUR package as root
What it means
prepare_build rejects AUR package builds when the effective user ID is root. Building and installing AUR packages as root is unsafe: makepkg refuses to run as root, and PKGBUILDs execute arbitrary code, so paru bails before any build is scheduled. This is a deliberate safety policy, not an environment failure.
Solutions
- Run paru as a regular (non-root) user; paru will prompt for the sudo password itself when needed
- If you already ran paru with sudo, fix ownership of the paru cache: `sudo chown -R $USER:$USER ~/.cache/paru`
- In containers/CI, create a non-root user and run paru under it
- Use pacman directly for repository packages if root is genuinely required (repo packages do not hit this path)
Example fix
// before $ sudo paru -S yay error: can't install AUR package as root // after $ paru -S yay # run as normal user; paru escalates internally
Defensive patterns
Strategy: validation
Validate before calling
if nix::unistd::getuid().is_root() {
eprintln!("refusing to run paru as root; run as a normal user");
std::process::exit(1);
} Prevention
- Never prefix paru with sudo; it escalates itself
- Create a build user in containers/CI before invoking paru
- Keep ~/.cache/paru owned by your normal user
When it happens
Trigger: Calling install/prepare_build (via resolve_targets) when actions.build is non-empty (AUR packages to build) and nix::unistd::getuid().is_root() is true — e.g. running `sudo paru -S <aur-pkg>` or `paru -S <aur-pkg>` inside a root shell/container.
Common situations: Users running `sudo paru ...` habitually (paru must run as a normal user; it escalates itself via sudo internally); Docker/CI containers that default to root; root shells on recovery/rescue sessions.
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
- duplicate PKGBUILD
- {}: {}: {}
- could not find .SRCINFO for
- packages failed to build
- package list does not match srcinfo
AI-assisted analysis of Morganamilo/paru@9ac3578807 (2026-09-12).
Data as JSON: /api/errors/9b406e417bf1f9f2.
Report an issue: GitHub.
Appendix: source
Thrown at src/install.rs:1077
return true;
}
if self.sysupgrade != 0 || self.refresh != 0 {
return false;
}
if ran_pacman {
return false;
}
aur_targets.is_empty() && upgrades.aur_keep.is_empty() && upgrades.pkgbuild_keep.is_empty()
}
async fn prepare_build(
&mut self,
config: &Config,
cache: &Cache,
actions: &mut Actions<'_>,
) -> Result<()> {
if !actions.build.is_empty() && nix::unistd::getuid().is_root() {
bail!(tr!("can't install AUR package as root"));
}
if !actions.build.is_empty() && config.args.has_arg("w", "downloadonly") {
bail!(tr!("--downloadonly can't be used for AUR packages"));
}
let conflicts = check_actions(config, actions, self.install_targets)?;
self.conflicts = conflicts
.0
.iter()
.map(|c| c.pkg.clone())
.chain(conflicts.1.iter().map(|c| c.pkg.clone()))
.collect::<HashSet<_>>();
let c = config.color;
print_warnings(config, cache, Some(actions));
View on GitHub (pinned to 9ac3578807)