pacman: <filename> exists in filesystem

When installing a package with pacman, I am seeing:

error: failed to commit transaction (conflicting files)
station: /usr/bin/station exists in filesystem

How do I tell pacman to install the package anyway, overwriting the existing file(s)?

Asked By: Tom Hale

||

Check what package includes the filename:

pacman -Qo filename

If it is another package, then file a bug report: packages which have conflicting files should mark themselves as CONFLICTS causing pacman to ask if you wish to replace the conflicting package.

If the files don’t belong to any package, rename or delete them.


If you’re sure you know what you’re doing, you can use the --overwrite option, eg:

pacman -S package-name --overwrite /usr/bin/station 

or

pacman -S package-name --overwrite '*'

The man page says:

   --overwrite <glob>
       Bypass file conflict checks and overwrite conflicting files. If the
       package that is about to be installed contains files that are
       already installed and match glob, this option will cause all those
       files to be overwritten. Using --overwrite will not allow
       overwriting a directory with a file or installing packages with
       conflicting files and directories. Multiple patterns can be
       specified by separating them with a comma. May be specified
       multiple times. Patterns can be negated, such that files matching
       them will not be overwritten, by prefixing them with an exclamation
       mark. Subsequent matches will override previous ones. A leading
       literal exclamation mark or backslash needs to be escaped.
Answered By: Tom Hale
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.