pacman: <filename> 存在于文件系统中

Tom*_*ale 9 arch-linux pacman manjaro

使用 安装软件包时pacman,我看到:

error: failed to commit transaction (conflicting files)
station: /usr/bin/station exists in filesystem
Run Code Online (Sandbox Code Playgroud)

pacman无论如何,我如何告诉安装软件包,覆盖现有文件?

Tom*_*ale 19

检查包含文件名的包:

pacman -Qo filename
Run Code Online (Sandbox Code Playgroud)

如果它是另一个包,则提交错误报告:具有冲突文件的包应将自己标记为CONFLICTS导致pacman询问您是否希望替换冲突包。

如果文件不属于任何包,请重命名或删除它们。


如果您确定自己知道自己在做什么,则可以使用该--overwrite选项,例如:

pacman -S package-name --overwrite /usr/bin/station 
Run Code Online (Sandbox Code Playgroud)

或者

pacman -S package-name --overwrite '*'
Run Code Online (Sandbox Code Playgroud)

手册页说:

   --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.
Run Code Online (Sandbox Code Playgroud)

  • Arch Wiki 特别[建议避免`--overwrite`](https://wiki.archlinux.org/index.php/System_maintenance#Avoid_certain_pacman_commands),除非作为最后的手段。正确的方法是移动冲突文件并完成安装。 (4认同)