Error: failed to commit transaction (conflicting files) (SOLVED)
September 24, 2023
When performing updates on Arch Linux and derivative distributions (Manjaro, BlackArch), several checks are performed before directly installing new versions of packages:
- checking if all necessary dependencies are present
- checking if there are conflicting packages
The previous two checks are performed before the installation files are downloaded.
Immediately after downloading the installation files (but, of course, even before installing them), a number of checks are performed:
- checking keys in keyring
- checking the integrity of downloaded packages
- checking the available disk space – if there is not enough disk space to install packages, the update (or installation) will be stopped
- a check is performed for conflicting files. Conflicting files are files in your Linux that are located in the same directories and have the same name as the files in the installation packages, but they do not belong to older versions of the packages.
All of these checks are automatic and usually do not cause any problems. But there are exceptions. For example, the command to completely update the Arch Linux operating system:
pacman -Syu
On my operating system it caused the following error:
:: Synchronizing package databases... core 128.5 KiB 489 KiB/s 00:00 [######################] 100% extra 8.3 MiB 14.9 MiB/s 00:01 [######################] 100% community 45.0 B 803 B/s 00:00 [######################] 100% multilib 143.6 KiB 2.00 MiB/s 00:00 [######################] 100% blackarch is up to date :: Starting full system upgrade... resolving dependencies... looking for conflicting packages... Packages (4) boost-libs-1.83.0-2 python-appdirs-1.4.4-9 python-argparse-1.4.0-15 python-jaraco.functools-3.9.0-1 Total Download Size: 2.32 MiB Total Installed Size: 8.50 MiB Net Upgrade Size: -0.19 MiB :: Proceed with installation? [Y/n] :: Retrieving packages... boost-libs-1.83.... 2.3 MiB 14.2 MiB/s 00:00 [######################] 100% python-argparse-... 22.0 KiB 173 KiB/s 00:00 [######################] 100% python-appdirs-1... 17.3 KiB 309 KiB/s 00:00 [######################] 100% python-jaraco.fu... 16.6 KiB 276 KiB/s 00:00 [######################] 100% Total (4/4) 2.3 MiB 3.65 MiB/s 00:01 [######################] 100% (4/4) checking keys in keyring [######################] 100% (4/4) checking package integrity [######################] 100% (4/4) loading package files [######################] 100% (4/4) checking for file conflicts [######################] 100% error: failed to commit transaction (conflicting files) python-argparse: /usr/lib/python3.11/site-packages/argparse-1.4.0.dist-info/INSTALLER exists in filesystem python-argparse: /usr/lib/python3.11/site-packages/argparse-1.4.0.dist-info/METADATA exists in filesystem python-argparse: /usr/lib/python3.11/site-packages/argparse-1.4.0.dist-info/RECORD exists in filesystem python-argparse: /usr/lib/python3.11/site-packages/argparse-1.4.0.dist-info/WHEEL exists in filesystem python-argparse: /usr/lib/python3.11/site-packages/argparse-1.4.0.dist-info/top_level.txt exists in filesystem Errors occurred, no packages were upgraded.
The last line says:
Errors occurred, no packages were upgraded.
That is, the packages were not updated due to an error.
But the main message that will help us understand the problem is contained above, namely in the line:
error: failed to commit transaction (conflicting files)
That is, the main reason is file conflict.
The following lines specify which packages conflict with which files. The line begins with the name of the package to be installed, and then, separated by a colon, specifies a file that is already contained in the file system and which prevents the installation of the package, since this package contains a file with exactly the same location. It should be noted that files in older versions of packages do not cause this error because they are deleted automatically.
Typically file conflicts are caused by Python packages installed using PIP. For example, you installed the Python package with the pip3 command because an application would not work without it. And subsequently this package became a dependency for another application already installed on the system. As a result, during the next update, the system tries to install this package as a dependency, but files with the same names already exist.
The best solution in this case is to remove the package using the pip3 command, for example:
pip3 uninstall PACKAGE
Quite often, the name of the PIP package is the same as the name of the Python package in the repository, if you remove the string “python-” from the name.
But this does not always work, for example, some packages have uppercase letters in their names, and in repositories all package names are written in lowercase letters. There are other features of package naming.
To display a complete list of packages that are installed by PIP, run the following command:
pip list
See also: How to upgrade all Python packages in Kali Linux
In this list you can find the problematic package and remove it using a command like:
pip3 uninstall PACKAGE
This has worked for me dozens of times. But one day I was faced with the fact that this method did not work. The OS believed that the package that owned the problematic file was not installed and, therefore, there was nothing to remove.
If you are faced with the same stalemate, then one of the options to solve it is to overwrite the problematic file. That is, a file that already exists in the OS will be replaced by a file from the installed package.
This can be done with a command like:
sudo pacman -S --overwrite '/*' PACKAGE
In this command, replace PACKAGE with the package that you cannot install due to conflicting files. This will install the package and force the conflicting files to be overwritten.
For example, in my case the following command helped:
sudo pacman -S --overwrite '/*' python-argparse
Immediately after installing the problematic package, we were able to perform a complete update of the operating system.
See also: Analogue of the --force option in pacman
Conclusion
An error with one of the installation packages (for example, conflicting files) prevents both this package and all others from updating.
If a file conflict problem occurs, try to find out the cause of the problem and ensure that the file is removed using the same means by which it was installed – for example, using a different package manager. This is highly desirable, since if the same package is updated by different package managers, this can lead to both the package not working and similar errors to appear in the future.
And only if nothing helps and you really understand what you are doing, then install the problematic package by running pacman with the --overwrite option.
Related articles:
- How to install and use pikaur and makepkg on a server (93.8%)
- How to completely uninstall a package along with dependencies on Arch Linux (as well as BlackArch and Manjaro) (87%)
- How to view package information in Arch Linux (BlackArch, Manjaro) (87%)
- How to download a package without installation in Arch Linux and Manjaro. How to download the AUR package source code (87%)
- Error “cannot resolve dependency lib32 (32-bit library)” (SOLVED) (82.4%)
- Wine is missing from the context menu on Ubuntu (SOLVED) (RANDOM - 50.9%)