"Running makepkg as root is not allowed" and the user/sudo setup AUR builds require
The error text and cause are exact. pacman's scripts/makepkg.sh.in line 1122 is if (( EUID == 0 )) followed by the gettext string 'Running %s as root is not allowed as it can cause permanent,\ncatastrophic damage to your system.' and exit $E_ROOT, and libmakepkg/util/error.sh.in defines E_ROOT=10. The record's exit status is right. Steps 1, 2, 3, 5 and 6 are all correct, and the Omarchy claim is verified: bin/omarchy-pkg-aur-install runs yay -S --noconfirm as the invoking user with only a sudo-keepalive, never sudo yay.
Step 4 is the defect. runuser -u nobody -- makepkg will abort before building on almost any real PKGBUILD, because makepkg checks dependencies and, running as an unprivileged user with no sudo rights, cannot install them, so it exits with 'Missing dependencies'. The record installs no build dependencies anywhere in that path. Second, nobody's home directory is /, which is not writable, so any PKGBUILD carrying validpgpkeys fails source verification when gpg cannot create a keyring. Third, the framing overstates provenance: I could not find the nobody technique documented on the ArchWiki Makepkg or Arch User Repository pages, so 'the Arch-sanctioned escape hatch' is not supportable. It is a container convention, and the ArchWiki's actual position (Makepkg, 'Running makepkg itself as root is disallowed') points at a normal build user.
Do not "solve" this by adding %wheel ALL=(ALL) NOPASSWD: ALL to sudoers just to quiet an AUR helper. That hands every PKGBUILD you build unattended full root. Only chown paths inside your own home. Chowning system directories to fix build errors will break package ownership. Building as nobody in a shared /tmp directory means anyone on the box can tamper with the sources between download and build. Use it only in a single-user container or chroot.
Symptom
==> ERROR: Running makepkg as root is not allowed as it can cause permanent,
catastrophic damage to your system.
(makepkg exits with status 10.) With a helper:
Avoid running yay as root/sudo.
Usually hit when logged in as root on a fresh install with no ordinary user yet, inside a rescue chroot or container, or by habitually prefixing everything with sudo.
Cause
makepkg refuses to run with EUID 0 by design. A PKGBUILD is arbitrary shell executed at build time. As root it ignores every file permission and can write anywhere on the system. makepkg is built to run *unprivileged* and to escalate via sudo only for the specific pacman calls it makes (installing build dependencies, installing the finished package). So it needs a normal user with working sudo, the inverse of what people try.
Fix
Steps 1, 2, 3, 5 and 6 are unchanged. Replace step 4 with:
**4. Truly account-less environment (container, chroot).** The reliable pattern is a throwaway build user with passwordless sudo. This is what the official Arch container images do, and it is preferred over nobody because makepkg must be able to install build dependencies:
pacman -Sy --needed --noconfirm base-devel git sudo
useradd -m builder
echo 'builder ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/builder
chmod 0440 /etc/sudoers.d/builder
su - builder -c '
git clone https://aur.archlinux.org/PKGNAME.git ~/PKGNAME &&
cd ~/PKGNAME && makepkg -s --noconfirm
'
pacman -U /home/builder/PKGNAME/*.pkg.tar.zst
# clean up when the image is finished
rm -f /etc/sudoers.d/builder && userdel -r builder
If you genuinely cannot create a user, the nobody route works only if you install the build dependencies as root first and give nobody a writable HOME. Otherwise makepkg aborts on missing dependencies, and gpg source verification fails because nobody's home is /:
# read the PKGBUILD's depends/makedepends and install them AS ROOT first
install -d -o nobody -g nobody /tmp/build /tmp/build/home
cd /tmp/build
curl -LO https://aur.archlinux.org/cgit/aur.git/snapshot/PKGNAME.tar.gz
tar xf PKGNAME.tar.gz
chown -R nobody:nobody PKGNAME
cat PKGNAME/PKGBUILD # read depends= and makedepends=, then:
pacman -S --needed --noconfirm <those packages>
cd PKGNAME
runuser -u nobody -- env HOME=/tmp/build/home makepkg --nodeps --noconfirm
pacman -U ./*.pkg.tar.zst
--nodeps is required here: nobody has no sudo, so makepkg cannot install anything itself, which is exactly why you installed the dependencies as root above.
Verify
makepkg -si gets past source download into ==> Starting build()... and finishes with ==> Finished making: PKGNAME. pacman -Qi PKGNAME shows it installed. ls -l in the build directory shows files owned by your user, not root.