EDIT: READ THE THREAD BEFORE COPY-PASTING THE SOLUTION. There were a few other steps I had to take on my way there.
Hi everyone,
I think I’ve exhausted all of the solutions to the corrupted database issue existing in this forum and I’m slowly loosing my mind and getting ready to just nuke my whole setup.
tl;dr
❯ pamac update
...
Error: Failed to prepare transaction: invalid or corrupted database
What I’ve tried:
pamac update --force-refresh (succeed but resulted in all packages gone from the list of installed packages)
rm -rf /var/tmp/pamac/dbs/sync/* (same as above - even after pamac update my packages are gone from pamac updates)
If one must use pamac … then one should clean it regularly.
Probably the build directory specifically when trying to build from AUR and failing multiple times, and specifically the database when it complains about being corrupted.
pamac clean -b
pamac update --force-refresh
PS.
Are you sure about all your AUR packages ?
If you are still on Manjaro Stable branch with Plasma5 … then krunner5 is in the repos.
If you are on any other branch… then you are on Plasma6 and krunner5 should probably be removed.
PPS.
You really have not been doing your maintenance.
The [community] repo was deprecated a long time ago.
This probably also indicates you have ignored pacnews for however long.
To print them all you can do
❯ pamac clean -b
To delete: 19 files (1,3 GB)
Clean build files ? [y/N] y
==== AUTHENTICATING FOR org.manjaro.pamac.commit ====
Authentication is required to install, update, or remove packages
Authenticating as: Artur (artur)
Password:
==== AUTHENTICATION COMPLETE ====
❯ pamac update --force-refresh
Preparing...
Synchronizing package databases...
Refreshing core.db...
Refreshing extra.db...
Refreshing community.db...
Refreshing multilib.db...
Refreshing core.files...
Refreshing extra.files...
Refreshing community.files...
Refreshing multilib.files...
Refreshing AUR...
Nothing to do.
Transaction successfully finished.
What do I do now? That’s also what happened when I was removing the DBs manually last time. I have a backup of /var/tmp/pamac/dbs/sync/, I guess I need to restore it now?
I dont know why you would want to restore a backup of a corrupted database.
Just build them all again if you indeed need to.
But I will also mention a good number were not truly AUR packages. snapdv86dmhwd-nvidia krunner5pyside2python-hid-parserpython-mockpython-shiboken2electron25 if you are on Stable.
etc.
Besides those the rest are all git packages it may be noted.
(and I similarly wonder if they are installed on purpose…)
Besides that you still must handle your pacnews, including some that will change how your packages/repositories are synced.
Thank you for your engagement here, I’m doing my best to follow. I think I have a few new questions at this point:
Just build them all again if you indeed need to.
How do I go about it? My understanding was that pamac installed a good number of packages in my system and now it lost track of all of them. Do I need to manually reinstall all the packages? Should I restore the backup first to list all the packages I had before? Is this the solution that @Mirdarthos proposed?
But I will also mention a good number were not truly AUR packages.
I’m not sure how that happened. I was using almost exclusively the UI for package management, I’m not sure how I ended up in this place.
Besides those the rest are all git packages it may be noted.
I would guess they were installed as dependencies? Not sure.
Besides that you still must handle your pacnews, including some that will change how your packages/repositories are synced.
How do I do this? Until very recently I have lived in a naive assumption that everything is auto-magically handled for me by the powers of whatever lies behind the UI updater, my system has been fairly stable and updated for almost 5 years now.
Apologies for n00b questions, I’m trying to both solve the issue and understand how it happened to avoid it in the future.
If you want a magic GUI thing then manjaro-pacnew-checker exists, though I cannot vouch for it.
I use pacdiff+meld. As is shown in the wiki … and literally hundreds of forum posts here.
A quick example (and assuming no pre-existing configuration)
DIFFPROG=meld pacdiff -s
Of course it requires meld be installed, as well as pacman-contrib for pacdiff.
You will NEED to handle your pacnews.
This generally entails comparing the new defaults with your existing configurations.
The idea is to preserve important local options while importing new standards.
An example will be pacman.conf - the pacnew will show the removal of the community repo.
Such changes MUST be made to keep your system in sync.
Other pacnews can have important impacts on your applications or system in general - but pacman.conf.pacnew is explicitly linked to how you install and update packages.
If you dont know … then they should probably be removed, but first we should make sure of some things.
Please tell me if you are on Stable branch or not.
pacman-mirrors -G
Once we have verified your branch status I can give you removal/rebuild commands as necessary.
If on stable and no inherent/known need for the extra git packages then we can point at reinstalling the repo equivalents to be sure. Lets sort mirrors and use pacman first also for good measure;
I will mention the 3 llvm llvm-libs clang … they are compiler things with repo equivalents.
But I dont think you actually want them. If you do add them to the string above.
Now try to remove everything that doesnt have a reason for being;
error: target not found: clang-opencl-headers-minimal-git
error: target not found: clang-build-analyzer-git
error: target not found: clang-format-static-bin
error: target not found: clangd-opt-git
error: target not found: clang-libs-minimal-git
error: target not found: clang-format-linter-git
error: target not found: llvm-rocm-git
error: target not found: llvm-git
error: target not found: clang-minimal-git
error: target not found: llvm-libs-minimal-git
error: target not found: llvm-libs-rocm-git
error: target not found: llvm-libs-git
Still pamac sees nothing, which I understand is not the desired scenario. This is all run after that previous pamac update --force-refresh cleared the list of packages visible to pamac.
oooh. So they werent ever installed?
I suppose they were trying to be built to be installed then, probably due to some quirk of dependencies while the sync status was askew (and that pamac has AUR enabled and does both at the same time).
So in that sense you have nothing to do then. At least in terms of foreign packages.
We can check, by asking pacman to print all foreign (not in repos) packages:
I think everything *breath* is just a theme. I’m pretty sure I didn’t explicitly install manjaro-documentation or manjaro-firmware or systemd-fsck-silent from non-repo/non-aur sources.
What should I do next then?
They were in the repos/aur at one point, but are not any longer.
You may notice for example that the firmware package was built in 2016.
Another quick check for you might be orphans.
pacman -Qdt
‘Orphans’ are packages that were installed as a dependency of another package, but are now not required by any installed package. Usually these should be safe to be removed, though it can happen that a package that was installed as a dependency is actually desirable but not marked ‘explicit’.
There are a few that I might want to keep, like alsa-card-profiles and sof-firmware.
For any you want to keep - mark them as explicitly installed.
sudo pacman -D --asexplicit PACKAGENAME
Then you can remove all orphans at once with
sudo pacman -Rns $(pacman -Qdtq)
For packages that dont exist in any repo … they are very ripe for removal.
Unless you have some good local reason for keeping them they should all be uninstalled.