pacman "exists on filesystem" error

After pacman finally deprecated the --force option and made the surrogate --overwrite option work as expected, the following usage pattern should be noted.

A command to reproduce the --force option that blindly overwrites anything that conflicts is this:

sudo pacman -S --overwrite \* <package_name>

Or

sudo pacman -S --overwrite "*" <package_name>

The tricky part is escaping the wildcard to stop the shell from expanding it first.


Ok, it looks like running sudo pacman -S --force <package-name> works, but it doesn't resolve conflicting directories. In such cases, running sudo rm -rf on the conflicting directories, followed by sudo pacman -S --force <package-name> works.

Now my pacman -Syu resolves well.


tl;dr: Uninstall the conflicting application before running pacman.

pacman (and other package managers) keep an index of packages and files that they manage (pacman --query --list). Some files, such as configuration, will be marked as modifiable and will not be overwritten during upgrade (except in special circumstances, where the package manager will typically move away the old file before creating the new one). Other files will be marked as unmodifiable. If another application changes those files in any way without updating the index accordingly there's no way for the package manager to know what to do with those files during an upgrade.

Many applications installed using the standard ./configure && make && sudo make install pattern can be uninstalled using sudo make uninstall. If you have installed the application in some other way you might have to something else to uninstall it. In general it can be a good idea to keep a copy of installation files somewhere (for example ~/install) to be able to reliably uninstall them in such cases. Just removing the conflicting files will probably leave other files lying around, which could conceivably cause other problems.

When installing software with other package managers there are ways to isolate those from the system files. This is an established best practice for example during software development, where you really want to keep versions consistent and avoid conflicts with other software. Examples include:

  • Python Virtualenv (example; in use)
  • Ruby Version Manager