Update or package installation returns “Failed to commit transaction (conflicting files); FILENAME exists in filesystem”

I can’t install or update a package because I get (something like) this:

error: could not prepare transaction
error: failed to commit transaction (conflicting files)
libname: /insert/file/name/here exists in filesystem
Errors occurred, no packages were upgraded.

Why is this happening?

The package manager, pacman, has detected an unexpected file already exists on disk. By design it will not overwrite files that already exist. This is a design feature, not a flaw - package managers are designed to keep track of installed files.

This issue normally happens because you’ve manually added, copied, or created a file. It can also happen when you install software using a downloaded executable, run a make install, or use a third-party package system such as conda. It also occurs when you install an AUR package which installs files that conflict with a repo package.

When using a third-party installer you should always specify an alternative installation location, such as under your home directory, or under /opt or /usr/local/. Never install directly under / or /usr.

How can I fix this?

The better way

The first step is to identify which, if any, package owns the file. This can be easily done with:

pacman -Qo /path/to/file

If this identifies a conflicting package you can decide to remove it with pacman -R. If no package is identified you can delete the file, e.g. rm /path/to/file (or move it to a backup location, e.g. mv /path/to/file /path/to/file.backup).

The faster way

pacman has an --overwrite option which will allow it to overwrite files. If you are sure you want to, you can tell it to

sudo pacman -S $PACKAGE --overwrite 'path/to/*'

This will (re)install the $PACKAGE and overwrite any files under the directory path/to/

This can be very useful if your local database has “lost” a package you’ve already installed (and so every file in the package “conflicts”).

The “I don’t care” way

sudo pacman -S $PACKAGE --overwrite '*'

Example

sudo pacman -S languagetool --overwrite usr/bin/languagetool,usr/share/java/languagetool/*

Where can I read more?

This post was inspired by (and adapted from):

https://bbs.archlinux.org/viewtopic.php?id=56373

The above post also has links to further reading.

Credit: Originally posted by Jonathon

11 Likes
[HowTo] Avoid pacman transaction failures
Failed to commit transaction (conflicting files)
Error: failed to commit transaction (conflicting files)
Multiple DEs installations and ownership of /etc/skel/.xinitrc
Update or package installation returns “error: failed to commit transaction (invalid or corrupted package)”
Pacman won't upgrade due to broken package
Update broke about removing python2-dbus breaks dependency 'python2-dbus' required by oblogout-manjaro
Manjaro is failing to update due to a missing file or folder
Can't update or install ferdi
After restarting the PC the desktop doesn´t show up
[Stable Update] 2021-03-18 - Kernels, Plasma, Frameworks, LibreOffice, Firefox, Systemd
[Testing Update] 2020-10-27 - KDE-git, Firefox, Deepin, Plasma 5.20.2, LibreOffice, Linux 5.10-rc1
Having issues with Updating
Error: failed to commit transaction (conflicting files) - python-pip ; /usr/lib/python3.8
Extreme error output during routine update
Is it safe to remove python-ufonormalizer?
NetBeans with jdk install error in Manjaro I3
Cannot Upgrade Anything
Makepkg -si : "Fehler: Konnte Paket nicht finden oder lesen"
[While updating] Error: failed to commit transaction (conflicting files)
General questions as well as install errors
Gnome-shell-extension-dash-to-dock - Error
Error: failed to commit transaction (conflicting files): singular owns conflicting files
Problems upgrading to Gnome 40
Missing dependency building vmware-workstation
How can i install gtkmm-4.0
Pacman -Syyu failing after updating
Failed to update: conflicting files
Issues with latest manjaro-zsh-config update
Pamac update fails - file already exists
Update didn't work because conflict, now I can't reinstall my DE
Libpamac and pamac-common package conflict
Failed to commit transaction (conflicting files) error
I have file conflicts while updating my system
[Stable Update] 2021-07-13 - Kernels, Plasma 5.22, Cinnamon 5, Gnome 40, LibreOffice, Mesa, Nvidia, Pamac
System Update error
File already exists in the filesystem
Cannot install Nvidia drivers after Manjaro update
Conflicting files during update
TrueCrypt from repo vs. install from original install file?