You are not logged in.

#1 2023-08-11 09:00:34

Mubin_Muhammad
Member
Registered: 2023-08-11
Posts: 3

I accidentally deleted /var/lib/pacman.

It might seem a copy of this post https://bbs.archlinux.org/viewtopic.php?id=262303.
But my problem is a bit different. I deleted the cache of pacman as well. For that, I deleted the /var/cache/pacman directory.
Then I got this message when ever I was trying to use pacman:

```bash
$ sudo pacman -Sy
error: failed to initialize alpm library:
(root: /, dbpath: /var/lib/pacman/)
could not find or read directory
```

Then I recreated the /var/lib/pacman folder with this command `sudo mkdir /var/lib/pacman`.
Then It did update pacman but, If I do `pacman -Q` that does not list any packages.
After that I thought that I will install sway (I already have it) and it tried to install it and didn't even show the  -- reinstalling  text.
And after it finishes installing it just gives a lot of messages saying that some file or directory already exists.
I don't know what to do.
So please help!

Thanks.

Offline

#2 2023-08-11 09:11:01

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,076

Re: I accidentally deleted /var/lib/pacman.

Follow the link I linked for instructions on how to restore the pacman database: https://wiki.archlinux.org/title/Pacman … l_database

You can basically "ignore" the cache matching helper script and just rely on the output the paclog command gives you.

Future note, pacman has the -Sc and -Scc command line switch that will safely and correctly clean out the cache, see also https://wiki.archlinux.org/title/Pacman … kage_cache for some other options.

Last edited by V1del (2023-08-11 09:12:18)

Offline

#3 2023-08-11 09:12:18

hcjl
Member
From: berlin
Registered: 2007-06-29
Posts: 330

Re: I accidentally deleted /var/lib/pacman.

Offline

#4 2023-08-11 11:43:26

Mubin_Muhammad
Member
Registered: 2023-08-11
Posts: 3

Re: I accidentally deleted /var/lib/pacman.

The link provided by V1del, told me to install the pacutils package to get paclog. I installed it with this command: sudo pacman -S pacutils. And this is my output:

pacman: /usr/share/man/man3/libalpm_packages.3.gz exists in filesystem
pacman: /usr/share/man/man3/libalpm_sig.3.gz exists in filesystem
pacman: /usr/share/man/man3/libalpm_trans.3.gz exists in filesystem
pacman: /usr/share/man/man5/BUILDINFO.5.gz exists in filesystem
pacman: /usr/share/man/man5/PKGBUILD.5.gz exists in filesystem
pacman: /usr/share/man/man5/alpm-hooks.5.gz exists in filesystem
pacman: /usr/share/man/man5/makepkg.conf.5.gz exists in filesystem
pacman: /usr/share/man/man5/pacman-hooks.5.gz exists in filesystem
pacman: /usr/share/man/man5/pacman.conf.5.gz exists in filesystem
pacman: /usr/share/man/man8/makepkg.8.gz exists in filesystem
pacman: /usr/share/man/man8/pacman-conf.8.gz exists in filesystem
pacman: /usr/share/man/man8/pacman-key.8.gz exists in filesystem
pacman: /usr/share/man/man8/pacman.8.gz exists in filesystem
pacman: /usr/share/man/man8/repo-add.8.gz exists in filesystem
pacman: /usr/share/man/man8/repo-remove.8.gz exists in filesystem
pacman: /usr/share/man/man8/vercmp.8.gz exists in filesystem
pacman: /usr/share/pacman/PKGBUILD-split.proto exists in filesystem
pacman: /usr/share/pacman/PKGBUILD-vcs.proto exists in filesystem
pacman: /usr/share/pacman/PKGBUILD.proto exists in filesystem
pacman: /usr/share/pacman/proto.install exists in filesystem
pacman: /usr/share/pkgconfig/libmakepkg.pc exists in filesystem
pacman: /usr/share/zsh/site-functions/_pacman exists in filesystem
Errors occurred, no packages were upgraded.

That exists in filesystem line continues for a long while. And alacritty can't even load them all.
And As you can see the last line says 'Errors occurred, no packages were upgraded.' that means pacutils did not install.
What do i do?

Offline

#5 2023-08-11 13:11:50

loqs
Member
Registered: 2014-03-06
Posts: 18,817

Re: I accidentally deleted /var/lib/pacman.

As the pacman's databases were removed I would suggest using the assume-installed option so pacman adds that dependency for this transaction:

# pacman -S --assume-installed=pacman=6.0.2-7

An alternative would be skipping dependency checks which normally you should never do but the only dependency is pacman and it can not be resolved with the broken databases:

# pacman -Sdd pacutils

Offline

#6 2023-08-12 04:08:44

Mubin_Muhammad
Member
Registered: 2023-08-11
Posts: 3

Re: I accidentally deleted /var/lib/pacman.

I think I have to reinstall arch linux as things are not working as it did before.

Offline

#7 2023-08-12 06:15:12

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 73,714

Offline

Board footer

Powered by FluxBB