Find And Remove Conflicting Files Not Owned By Any Packages In Arch Linux

Graphical Frontends for Pacman

Today, I ran into problem – “error: failed to commit transaction (conflicting files)” while I tried to install a package in my Arch Linux desktop. It kept throwing the errors when I try to install any packages with Python dependencies. Here is the sample output while I try to install or update any package.

error: failed to commit transaction (conflicting files)
python-requests: /usr/lib/python3.6/site-packages/requests/__init__.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/__pycache__/__init__.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/__pycache__/_internal_utils.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/__pycache__/adapters.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/__pycache__/api.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/__pycache__/auth.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/__pycache__/certs.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/__pycache__/compat.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/__pycache__/cookies.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/__pycache__/exceptions.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/__pycache__/hooks.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/__pycache__/models.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/__pycache__/sessions.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/__pycache__/status_codes.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/__pycache__/structures.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/__pycache__/utils.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/_internal_utils.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/adapters.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/api.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/auth.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/certs.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/compat.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/cookies.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/exceptions.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/hooks.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/models.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/__init__.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/__pycache__/__init__.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/idna/__init__.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/idna/__pycache__/__init__.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/idna/__pycache__/codec.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/idna/__pycache__/compat.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/idna/__pycache__/core.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/idna/__pycache__/idnadata.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/idna/__pycache__/intranges.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/idna/__pycache__/uts46data.cpython-36.pyc exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/idna/codec.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/idna/compat.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/idna/core.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/idna/idnadata.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/idna/intranges.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/packages/idna/uts46data.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/sessions.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/status_codes.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/structures.py exists in filesystem
python-requests: /usr/lib/python3.6/site-packages/requests/utils.py exists in filesystem
Errors occurred, no packages were upgraded.

After a bit search on Arch Linux wiki page, I found that the reason could be pacman has detected a file conflict, and It will not overwrite files for you. This kind of error might occur when your Arch Linux system was likely shut down uncleanly during or directly after a pacman operation. This left you with a broken pacman database and empty files.

Remove Conflicting Files Not Owned By Any Packages In Arch Linux

The solution to fix this error is you can force pacman to overwrite those conflicting files using command:

sudo pacman -S --force <package-name>

If it doesn’t help, you need to find if those files are not owned by any package, and either delete or rename them.

To find whether the files are owned by any package as shown below. In my case, I ran the following command:

sudo pacman -Qo /usr/lib/python3.6/site-packages/requests/__init__.py

The above command will check if there is any package owns /usr/lib/python3.6/site-packages/requests/__init__.py or not.

Sample output:

error: No package owns /usr/lib/python3.6/site-packages/requests/__init__.py

As you see in the above example, no package owns __init__.py file. I checked all files in the above output. None of them are owned by any packages. So, if you find such kind of files which are not owned by any package, just rename or delete these files. Before deleting them, just backup those files ( i.e all files inside /usr/lib/python3.6/site-packages/requests/ directory), so you can restore them in case anything goes wrong.

In my case, I made a backup all contents of /usr/lib/python3.6/site-packages/requests/ folder.

cp -fr /usr/lib/python3.6/site-packages/requests/. backup/

Then, I deleted all files in the above output.

sudo /usr/lib/python3.6/site-packages/requests/__init__.py
[...]
sudo rm -fr /usr/lib/python3.6/site-packages/requests/utils.py

This time I can be able to install the package without any errors.

Hope this helps. If you find this helpful, please share it on your social, professional networks, and support OSTechNix.

Cheers!

Happy weekend!!

Resource:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You may also like...