GNU/Linux >> Belajar Linux >  >> Arch Linux

Temukan Dan Hapus File yang Bertentangan yang Tidak Dimiliki oleh Paket Apa Pun Di Arch Linux

Hari ini, saya mengalami masalah - "kesalahan:gagal melakukan transaksi (file bentrok)" ketika saya mencoba menginstal paket di desktop Arch Linux saya. Itu terus menimbulkan kesalahan ketika saya mencoba menginstal paket apa pun dengan dependensi Python. Berikut adalah contoh keluarannya saat saya mencoba memasang atau memperbarui paket apa pun.

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.

Setelah sedikit mencari di halaman wiki Arch Linux, saya menemukan bahwa alasannya mungkin - "pacman telah mendeteksi konflik file, dan itu tidak akan menimpa file untuk Anda" . Kesalahan semacam ini mungkin terjadi ketika sistem Arch Linux Anda mungkin dimatikan secara tidak benar selama atau langsung setelah operasi pacman. Ini meninggalkan Anda dengan database pacman yang rusak dan file kosong.

Hapus File yang Bertentangan yang Tidak Dimiliki oleh Paket Apa Pun Di Arch Linux

Solusi untuk memperbaiki kesalahan ini adalah dengan memaksa pacman untuk menimpa file yang bertentangan tersebut menggunakan perintah:

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

Jika tidak membantu, Anda perlu menemukan apakah file tersebut tidak dimiliki oleh paket apa pun, lalu Anda harus menghapus atau mengganti namanya.

Untuk menemukan apakah file dimiliki oleh paket apa pun seperti yang ditunjukkan di bawah ini. Dalam kasus saya, saya menjalankan perintah berikut:

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

Perintah di atas akan memeriksa apakah ada paket yang memiliki /usr/lib/python3.6/site-packages/requests/__init__.py atau tidak.

Contoh keluaran:

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

Seperti yang Anda lihat pada contoh di atas, tidak ada paket yang memiliki __init__.py mengajukan. Saya memeriksa semua file dalam output di atas. Tak satu pun dari mereka dimiliki oleh paket apa pun. Jadi, jika Anda menemukan file apa pun yang tidak dimiliki oleh paket apa pun, cukup ganti nama atau hapus file-file ini. Sebelum menghapusnya, cukup buat cadangan file tersebut (yaitu semua file di dalam /usr/lib/python3.6/site-packages/requests/ direktori), sehingga Anda dapat memulihkannya jika terjadi kesalahan.

Dalam kasus saya, saya mencadangkan semua konten /usr/lib/python3.6/site-packages/requests/ folder.

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

Kemudian, saya menghapus semua file pada output di atas.

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

Kali ini saya dapat menginstal paket tanpa kesalahan.


Arch Linux
  1. Cara Menemukan Paket Rentan Di Arch Linux

  2. Memecahkan "ERROR:'pacman' gagal menginstal dependensi yang hilang" Di Arch Linux

  3. Bagaimana Linux Menangani Beberapa Pemisah Jalur Berturut-turut (/home////username///file)?

  1. Perbedaan Antara /opt Dan /usr/local?

  2. temukan dan hapus file dengan ruang menggunakan perintah find di Linux

  3. Instal binari ke /bin, /sbin, /usr/bin dan /usr/sbin, interaksi dengan --prefix dan DESTDIR

  1. /usr/bin Vs /usr/local/bin Di Linux?

  2. Linux – Menggabungkan /usr/bin Dan /usr/sbin Ke /bin (gnu/linux)?

  3. Haruskah situs web berada di /var/ atau /usr/ sesuai dengan penggunaan yang disarankan?