You are not logged in.

#1 2018-10-14 14:34:39

Sakkaku
Member
Registered: 2017-08-08
Posts: 16

Pacman command not found.

So apparently it happend again. The last time it happened I just reinstall Arch Linux completely. But I do not want to do that again.

While trying to install something, in this case 'base-devel', it tried to reinstall pacman too. But it failed to find the pacman file somewhere in /var/cache/pacman/... and it stopped. Now the pacman command is gone and I have no idea how to get it back.

I tried to download pacman tar file and build it. But I am getting errors when I try to run 'make'. So I just give up and hope someone here can help me. Is there no easy way to restore pacman?

Offline

#2 2018-10-14 14:47:06

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 21,902
Website

Re: Pacman command not found.

https://wiki.archlinux.org/index.php/Pa … ing_pacman

or

https://aur.archlinux.org/packages/pacman-static/
https://wiki.archlinux.org/index.php/Un … #eschwartz

or boot a live iso, mount your relevant partitions, then use pacman from the iso (with the -r flag) to install pacman to your system: there is no need to reinstall the whole system if just pacman is missing.

Last edited by Trilby (2018-10-14 15:28:49)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2018-10-14 15:25:59

Morganamilo
Member
Registered: 2017-12-05
Posts: 69

Re: Pacman command not found.

Did you happen to symlink the pacman cache dir? That's a bad idea and will lead to... well... your current situation.
Instead configure a different cache dir or use a bind mount.

Offline

#4 2018-10-14 15:35:26

eschwartz
Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 2,853

Re: Pacman command not found.

I'm guessing that your /var/cache/pacman/pkg directory is a symlink to something else. This is wrong and should not be done, ever. The directory is owned by pacman packages, and you don't have permission to modify it and turn it into a file.

As a result, one pacman package uninstalled the old /var/cache symlink itself, and installed the directory entry from the package as a replacement -- thus causing the succeeding packages to disappear from pacman mid-transaction. Having pacman itself disappear in the resulting error is simply the worst-case scenario. This is a pacman bug tracked as https://bugs.archlinux.org/task/58804 since pacman should fatally abort with a "conflicting file" error rather than attempt to do anything at all

There's two solutions to moving your cachedir properly:

  • Use a bind mount to mount some other directory on top of /var/cache/ or /var/cache/pacman/pkg/ instead of using a symlink.

  • Leave /var/cache/pacman/pkg/ alone and use pacman.conf's CacheDir setting to use a different location for pacman specifically. (Does not apply to moving all general system caches.)

And as Trilby said, you can manually acquire the necessary pacman binary and use that -- or boot to the installation media, but rather than reinstalling, simply use pacman's --root option to reinstall pacman into /mnt/my_archlinux_install.

Last edited by eschwartz (2018-10-14 15:41:22)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#5 2018-10-14 18:02:38

Sakkaku
Member
Registered: 2017-08-08
Posts: 16

Re: Pacman command not found.

Thanks for all the help. I just installed pacman via the installation media and I am not going to symlink the folder again. I will now just clear the cache now and then.

Offline

#6 2018-10-14 18:29:01

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 21,902
Website

Re: Pacman command not found.

By clearing the cache I hope you are referring to proper use of `paccache`.  If not, you should learn to use it.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2018-10-15 08:28:27

-MacNuke-
Member
Registered: 2013-01-29
Posts: 21

Re: Pacman command not found.

Install pacman-contrib, put the stuff below into /etc/pacman.d/hooks/paccache.hook and forget the cache altogether.

[Trigger]
Operation = Remove
Operation = Install
Operation = Upgrade
Type = Package
Target = *

[Action]
Description = Keep the last two cached and the currently installed.
When = PostTransaction
Exec = /usr/bin/paccache -r

Last edited by -MacNuke- (2018-10-15 08:32:51)

Offline

#8 2018-10-15 17:38:20

arisinfenix
Member
From: Germany
Registered: 2018-06-20
Posts: 29

Re: Pacman command not found.

The pacman-contrib package also provides a systemd-timer that runs paccache -r weekly if enabled.

systemctl enable paccache.timer

Offline

#9 2019-01-13 13:25:36

remus
Member
Registered: 2015-11-03
Posts: 33

Re: Pacman command not found.

I managed to do the same to my system. Thanks for everyone’s help here!
(Side note: Symlinking directories that can grow to considerable size (I always remove all but the last three versions for each package, but the package cache directory still has almost 5 GB) seems to me to be a very common pattern, so if it really is so incredibly dangerous in this specific case, I really feel like there should be some kind of warning or detection, instead of just telling people it was a terrible idea afterwards. But thanks, everyone, for sharing the proper way to do this! I will probably stick to that in the future for other software, too, where possible – just in case.)

However, I unfortunately ran into further problems after following Pacman » Manually reinstalling pacman. While just downloading and unpacking the pacman package worked perfectly fine to give me back all the binaries, Pacman still isn’t able to properly re-install the package afterwards to get the package DB in sync. I get the following:

# pacman -U pacman-5.1.2-2-x86_64.pkg.tar.xz 
loading packages...
warning: pacman-5.1.2-2 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...
error: could not open file /var/lib/pacman/local/pacman-5.1.2-2/desc: No such file or directory
warning: could not fully load metadata for package pacman-5.1.2-2
error: failed to prepare transaction (invalid or corrupted package)

The “/var/lib/pacman/local/pacman-5.1.2-2/” directory exists, but is empty, on my system. Is there any way to reconstruct it? Pacman/Restore local database sounded promising, but ultimately just consists of adding more flags to the above call (as far as I can see), none of which really changed the output (except “--needed”, which prevented it from doing anything).

Should/can I just delete the “/var/lib/pacman/local/pacman-5.1.2-2/” directory to fool Pacman into completely reinstalling itself? Or is there some way to get the “desc” file back (and, apparently, also “files” and “mtree”, except if they’re not needed when re-installing)?

Booting from a live ISO and re-installing that way might of course also work, but since I have it basically working now, it seems riskier to do that than to try to just fix the remaining small problem (if that’s easily possible).

Thanks in advance!

Offline

#10 2019-01-13 14:26:42

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 8,921
Website

Re: Pacman command not found.

Delete the '/var/lib/pacman/local/pacman-5.1.2-2/' directory and then add `--dbonly` to  the reinstall command, e.g. `pacman -U --dbonly pacman-5.1.2-2-x86_64.pkg.tar.xz`. (Note: it is important to reinstall the database entry for the exact same version pacman previously thought it had). This will re-create db entry. `pacman -Qkk pacman` will then tell you whether there are any potentially damaged files.

If you need any further assistance with this problem, please open a new topic, and link back to this one if it is still relevant.

https://wiki.archlinux.org/index.php/Co … bumping%22


Closing.


Sakura:-
Mobo: MSI X299 TOMAHAWK ARCTIC // Processor: Intel Core i7-7820X 3.6GHz // GFX: nVidia GeForce GTX 970 // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 5x 1TB HDD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB