Fix 'could not register database (database already registered)'
Thread 191802: Trilby says the error only occurs when a repository is listed twice and Allan says pacman 4.2 got stricter about it, which supports the cause. Omarchy 4's /etc/pacman.conf enables [multilib] (confirmed locally), and omarchy-refresh-pacman replaces the whole file (read on 4.0.4-1). The diagnosis step is still incomplete. pacman.conf allows globs in Include =, and the record's xargs -r grep passes the glob through literally, so a duplicate brought in by Include = /etc/pacman.d/*.conf is never shown, with the error hidden by 2>/dev/null. Tested here on a copy of pacman.conf with a glob Include carrying a second [multilib]: the record's command printed nothing. A shell loop with an unquoted variable expands the glob and found it. pacman-conf --config <copy> --repo-list does not refuse duplicates. It printed multilib twice, so pacman-conf --repo-list | sort | uniq -d names the duplicate directly and is now the first step. Nothing was edited on the live file.
Symptom
Every pacman or AUR helper command starts with an error, and some refuse to run:
error: could not register 'multilib' database (database already registered)
The repository name varies: multilib, chaotic-aur, sublime-text, or any third-party repo. It often starts right after following a guide that said to add a repository.
Cause
The same repository section appears twice in /etc/pacman.conf, or once in pacman.conf and again in a file it pulls in with Include =. Since pacman 4.2 a duplicate section name is rejected rather than silently merged. A common way to get here is adding [multilib] from the Arch wiki to a pacman.conf that already enables it (Omarchy 4's pacman.conf already has [multilib] enabled), or running a repository setup script twice.
Fix
Name the duplicated repository. pacman-conf reads pacman.conf and every file it includes, globs too, and lists a duplicate twice instead of refusing it:
pacman-conf --repo-list | sort | uniq -d
Find where each copy is defined, in pacman.conf and in every included file (the loop expands glob Include = lines, which xargs would not):
grep -n '^\[' /etc/pacman.conf
for inc in $(sed -n 's/^[[:space:]]*Include[[:space:]]*=[[:space:]]*//p' /etc/pacman.conf | sort -u); do grep -Hn '^\[' $inc; done 2>/dev/null
Back up the file, then delete one complete copy of that section (its [name] line and the Include = or Server = and SigLevel = lines under it). Keep the one in the position you want, because order sets repository priority. If the second copy sits inside an included file, remove it there, or remove the Include = line that pulls it in:
sudo cp /etc/pacman.conf /etc/pacman.conf.bak
sudoedit /etc/pacman.conf
Then confirm that the first command prints nothing, and upgrade:
pacman-conf --repo-list | sort | uniq -d
**Omarchy 4:** omarchy update. **Plain Arch:** sudo pacman -Syu.
On Omarchy 4, omarchy refresh pacman also clears duplicates because it replaces the whole file, but it drops every third-party repository too.
Verify
pacman-conf --repo-list lists each repository exactly once and pacman commands run without the error.