Failed to prepare transaction: target not found

Hi there, sorry to post about this recurring issue, but I’ve tried other forum fixes and they helped and made things worse, I think.

To give the full story: at some point my Add/Remove Software app broke. Whenever I tried to update I would get the error message “Failure to prepare transaction” with an additional “invalid or corrupted database”. I found this post, went into Konsole, and entered:
sudo rm -R /var/lib/pacman/sync
sudo -E pacman -Syu

This seemed to update my apps, and I thought everything was fixed. However, when I went back into Add/Remove Software, I could no longer download or update anything. In addition to the original error messages, I now get “target not found: appname” for new apps I’m trying to download. It’s like I have a database filled with broken links.

This is a bit of a nightmare for me, as I use this laptop for work, and I have a new semester coming up soon. I’m new to Linux but trying my hardest to understand. I’ve picked up that there seem to be two updaters: pamac and pacman? One is for AUR and the other for Arch distributions?

I also have this output, from a different fix I tried earlier (that resulted in the same errors, unfortunately).
pamac update --force-refresh

> Synchronizing package databases...
> Error: GPGME error: No data
> Error: GPGME error: No data
> Error: GPGME error: No data
> Refreshing core.db...                                                                                         
> Refreshing extra.db...                                                                                        
> Refreshing multilib.db...                                                                                     
> Error: GPGME error: No data                                                                                   
> Error: GPGME error: No data
> Error: GPGME error: No data
> invalid or corrupted database (PGP signature)
> Error: GPGME error: No data
> Error: GPGME error: No data
> Error: GPGME error: No data
> Refreshing core.files...                                                                                      
> Refreshing extra.files...                                                                                     
> Refreshing multilib.files...                                                                                  
> Error: GPGME error: No data                                                                                   
> Error: GPGME error: No data
> Error: GPGME error: No data
> invalid or corrupted database (PGP signature)
> Failed to synchronize databases
> Refreshing AUR...                                                                                             
> cp: cannot access '/var/lib/pacman/sync/download-b4DkJF': Permission denied                                   
> Nothing to do.
> Cloning ckbcomp build files...
> Generating ckbcomp information...
> Checking ckbcomp dependencies...
> Cloning pamac-tray-icon-plasma build files...
> Generating pamac-tray-icon-plasma information...
> Checking pamac-tray-icon-plasma dependencies...
> Cloning onlyoffice-bin build files...
> Generating onlyoffice-bin information...
> Checking onlyoffice-bin dependencies...
> cp: cannot access '/var/lib/pacman/sync/download-b4DkJF': Permission denied
> cp: cannot access '/var/lib/pacman/sync/download-BodkOq': Permission denied
> Error: Failed to prepare transaction: invalid or corrupted database

Hi @mitakiharashi, and welcome!

Yes. And no.

pacman is the original package management program inherited from Arch Linux, which Manjaro is forked frrom.

pamac was developed for Manjaro, by Manjaro. It might use pacman’s libalpm, but it is a standalone application that can function on it’s own.

Your error does, indeed, seem to indicate that the package database, and thus links are out of sync. I suggest you:

  1. Remove the current, faulty database:

    sudo rm -r /var/lib/pacman/sync
    
  2. Update your mirrors:

    sudo pacman-mirrors --fasttrack=5
    
  3. Update your package list, and the system while you’re at it:

    sudo pacman -Syu
    
  4. And then try again to do what you wanted to do and see if it works now.

Hope this helps!

  • sudo pacman -Syu runs pacman with root privilege, resetting most environment variables and it is the right way to run pacman.
  • -E tells sudo to preserve environment variables, passing on PATH etc. If you have custom settings, it can go wrong… and /etc/pacman.d/hooks are configured for default settings.

I’m not sure that was the right course of action - I would have recommended the same, with no -E (mostly because I don’t have a specific reason, and I really don’t understand most of the risks).

GPG signature verification and permission errors.

First, try refreshing the keyring:

sudo pacman -Sy --needed manjaro-keyring  archlinux-keyring && sudo pacman -Su

You might need to reset and reinitialise your keys:

sudo rm -rf /etc/pacman.d/gnupg
sudo pacman-key --init
sudo pacman-key --populate archlinux manjaro  # Populate both keyrings
sudo pacman-key --refresh-keys

Manjaro uses systemd timers - we have archlinux-keyring-wkd-sync.service which should auto-refresh keys weekly…

The archlinux-keyring would apply mostly to AUR packages I think… so manjaro-keyring is key (sic) here :stuck_out_tongue:

Thanks for the welcome and fast responses :slight_smile:

I’m actually not sure which method fixed things. I first tried @Mirdarthos’s fix, then when nothing seemed to change, I tried @Ben’s fix, which also didn’t change anything. I was still getting the error “Failure to prepare transaction”.

It wasn’t until I restarted my computer that Add/Remove Software worked again, which is a bit embarrassing (“have you tried turning it on and off?”). I imagine the restart properly wiped the old databases from memory, and connected pamac to the new ones.

Regardless of which solution worked, thank you both for the help! I was quite distressed at the thought of reinstalling Manjaro. :pray: :pray: :pray:

Probably one of the systemd timers or services, and nothing we instructed.

:wink:

But glad it’s working now.

It happens, there are always some gremlins hiding in the works to defy all logical steps…

:vulcan_salute: