Update crashed - pacman corrupt

My last update from 12/24/22 crashed on my laptop:

(209/243) Aktualisiert wird libmpc                                                                                              [#############################################################################] 100%
(210/243) Aktualisiert wird pacman-mirrors                                                                                      [#############################################################################] 100%
Fehler: Konnte Datei /var/cache/pacman/pkg/pacman-6.0.2-6-x86_64.pkg.tar.zst nicht öffnen: Datei oder Verzeichnis nicht gefunden
Fehler: Konnte den Vorgang nicht durchführen
Fehler: Der Vorgang konnte nicht durchgeführt werden (Vorgang abgebrochen)
Fehler sind aufgetreten, keine Pakete wurden aktualisiert.

After that, I found, that a link (/var/cache/pacman → /mnt/linux2root/var/cache/pacman) is deleted during the update. I created this link weeks before because of low disk space on the / partition.

I create the link again, but cannot finish the update because “pacman” is not found.

Another way to update also don’t work:

pamac update                                                                                                                                                                                                 
pamac: error while loading shared libraries: libalpm.so.13: cannot open shared object file: No such file or directory

I can solve this with copying the file /lib/libalpm.so.13.0.2 from my desktop and create the missing links.
Now pamac starts, but during “pamac update” error occur:

Warning: could not fully load metadata for package pacman-6.0.2-6
Error: ... invalid or corrupted package

Has anyone a idea, how to get pacman working again?

pamac reinstall pacman

leads to the same error. Remove of pacman also don’t work.

In /var/cache/pacman/pkg I have older packages of pacman, but how to install these?

Thanks in advance

Matthias

May be pacman-static helps :wink:

core/pacman-static 6.0.2-3
    Statically-compiled pacman (to fix or install systems without libc)

How to boot from USB into live Manjaro (for repair):


Instead of a link you could do a mount

You’re improperly manipulating the location of the cache directory: it “belongs” to the pacman package and during the update of said package your symlink is removed and a directory (re-)created. That leads to an empty package cache during your update.

Use a bind mount

$ sudo mount --bind /mnt/linux2root/var/cache/pacman /var/cache/pacman

or adjust the cache location in /etc/pacman.conf:

#CacheDir    = /var/cache/pacman/pkg/
CacheDir    = /mnt/linux2root/var/cache/pacman/pkg/

Also see arch wiki mentioning this:
https://wiki.archlinux.org/title/pacman#pacman:_command_not_found

You can manually install pacman from your cache directory to restore your package manager. This is also described in arch wiki:
https://wiki.archlinux.org/title/pacman#Manually_reinstalling_pacman

At first: Thank you!

I change the CacheDir in /etc/pacman.conf and delete the link.

Then I extract the /usr files from the package pacman-6.0.2-6-x86_64.pkg.tar.zst in cache.
Now I can execute pacman, but a reinstall don’t work:

sudo pacman -U --overwrite "*" pacman-6.0.2-6-x86_64.pkg.tar.zst                                                                                                                           
Pakete werden geladen …
Warnung: pacman-6.0.2-6 ist aktuell -- Reinstalliere
Abhängigkeiten werden aufgelöst …
Nach in Konflikt stehenden Paketen wird gesucht …
Warnung: Konnte die Metadaten für Paket pacman-6.0.2-6 nicht vollständig laden
Fehler: Vorgang konnte nicht vorbereitet werden (Ungültiges oder beschädigtes Paket)

Install of pacman-static leads to the same error.

Do you see the same error when just trying to install?

$ sudo pacman -Syu pacman

Yes:

:: Paketdatenbanken werden synchronisiert …
 core ist aktuell
 extra ist aktuell
 community                                                                                            7,5 MiB  9,43 MiB/s 00:01 [#############################################################################] 100%
 multilib ist aktuell
Warnung: pacman-6.0.2-6 ist aktuell -- Reinstalliere
:: Vollständige Systemaktualisierung wird gestartet …
Warnung: sndio: Lokale Version (20180120-1) ist neuer als community (1.9.0-1)
Abhängigkeiten werden aufgelöst …
Nach in Konflikt stehenden Paketen wird gesucht …
Warnung: Konnte die Metadaten für Paket pacman-6.0.2-6 nicht vollständig laden
Fehler: Vorgang konnte nicht vorbereitet werden (Ungültiges oder beschädigtes Paket)

I was able, to install pacman-static with octopi, but

sudo pacman-static -Syu pacman

leads to the same error.

try clearing your cache:
sudo pacman -Scc (yes to all)
and rerun update again

@brahma, this doesn’t help, same error.

do you have a manjaro usb? since you cant reinstall it even with pacman-static, we have to use external pacman from the usb, or pacstrap

Actually I have no Manjaro USB, but I can create one in the next days. Can you point me to a description, how to finish the update after boot the live-system?

boot into live usb and use pacstrap instead of external pacman from the live usb, i have a feeling that external pacman from the usb will not work either:
install it in the live usb:
sudo pacman -S arch-install-scripts
mount your root partition, for example:
sudo mount /dev/sda1 /mnt
where /dev/sda1 you replace with your partition; you can check them with:
lsblk -l
install pacman:
sudo pacstrap -i /mnt pacman
if you didnt get any error, you can reboot and rerun update

I try it, but it don’t work either:

I booted the Manjaro USB (from Image manjaro-kde-22.0-221224-linux61.iso), then install arch-install-scripts:

sudo pacman -Syu arch-install-scripts                                                        1 ✘
:: Synchronizing package databases...
 core                                  160,3 KiB   522 KiB/s 00:00 [####################################] 100%
 extra                                1829,0 KiB  8,01 MiB/s 00:00 [####################################] 100%
 community                               7,5 MiB  18,7 MiB/s 00:00 [####################################] 100%
 multilib                              166,4 KiB  2,90 MiB/s 00:00 [####################################] 100%
error: failed retrieving file 'core.db' from manjaro.moson.eu : Could not resolve host: manjaro.moson.eu
warning: too many errors from manjaro.moson.eu, skipping for the remainder of this transaction
error: failed retrieving file 'core.db' from mirror.infotronik.hu : The requested URL returned error: 404
error: failed retrieving file 'extra.db' from mirror.infotronik.hu : The requested URL returned error: 404
error: failed retrieving file 'community.db' from mirror.infotronik.hu : The requested URL returned error: 404
warning: too many errors from mirror.infotronik.hu, skipping for the remainder of this transaction
:: Starting full system upgrade...
resolving dependencies...
looking for conflicting packages...

Packages (1) arch-install-scripts-28-1

Total Download Size:   0,02 MiB
Total Installed Size:  0,05 MiB

:: Proceed with installation? [Y/n] y
:: Retrieving packages...
 arch-install-scripts-28-1-any          15,8 KiB   144 KiB/s 00:00 [####################################] 100%
(1/1) checking keys in keyring                                     [####################################] 100%
(1/1) checking package integrity                                   [####################################] 100%
(1/1) loading package files                                        [####################################] 100%
(1/1) checking for file conflicts                                  [####################################] 100%
(1/1) checking available disk space                                [####################################] 100%
:: Processing package changes...
(1/1) installing arch-install-scripts                              [####################################] 100%
:: Running post-transaction hooks...
(1/2) Arming ConditionNeedsUpdate...
(2/2) Refreshing PackageKit...

then mount my / partition to /mnt and run

sudo pacstrap -i /mnt pacman                                                                   ✔
==> Creating install root at /mnt
==> Installing packages to /mnt
:: Synchronizing package databases...
 core is up to date
 extra is up to date
 community is up to date
 multilib is up to date
error: failed retrieving file 'core.db' from manjaro.moson.eu : Could not resolve host: manjaro.moson.eu
warning: too many errors from manjaro.moson.eu, skipping for the remainder of this transaction
error: failed retrieving file 'core.db' from mirror.infotronik.hu : The requested URL returned error: 404
error: failed retrieving file 'extra.db' from mirror.infotronik.hu : The requested URL returned error: 404
error: failed retrieving file 'community.db' from mirror.infotronik.hu : The requested URL returned error: 404
warning: too many errors from mirror.infotronik.hu, skipping for the remainder of this transaction
warning: pacman-6.0.2-6 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...
warning: could not fully load metadata for package pacman-6.0.2-6
error: failed to prepare transaction (invalid or corrupted package)
==> ERROR: Failed to install packages to new root

well, thats not good…
try these commands:
sudo rm -r /var/lib/pacman/local/pacman-6.0.2-6
sudo pacman -S --dbonly pacman

@brahma, yes, delete of /var/lib/pacman/local/pacman-6.0.2-6 and dbonly-installation of pacman works!
After that I was able to finish the update with

sudo pacman -Syyu

and could restart with the kernel 6.0, which was not possible before.

Thank you very much!!

Matthias

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.