How to Downgrade a Package in Arch Linux

I needed to downgrade sops package to version 3.7.2 from 3.7.3 because of this issue.

There are several ways to downgrade a package or install a specific version of it in Arch Linux:

  • From the pacman cache

    1
    2
    3
    4
    5
    
    $ # Check available versions in the cache:
    $ ls /var/cache/pacman/pkg/sops*
    $ # Install it:
    $ sudo pacman -U \
      /var/cache/pacman/pkg/sops-3.7.2-1-x86_64.pkg.tar.zst
    
  • From the Arch Linux archive

    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    $ # Check available versions in the archive:
    $ curl -s https://archive.archlinux.org/packages/s/sops/
    $ # Another way to check:
    $ curl -s https://archive.archlinux.org/packages/.all/index.0.xz \
      | xz -d \
      | grep sops
    $ # Install it:
    $ sudo pacman -U \
      https://archive.archlinux.org/packages/.all/sops-3.7.2-1-x86_64.pkg.tar.zst
    
  • From the AUR (sometimes there are older versions for backward compatibility)

    1
    2
    
    $ yay sops
    $ # See what you've got ...
    
  • Build from the AUR

    1
    2
    3
    4
    5
    
    $ git clone https://aur.archlinux.org/sops-git.git
    $ cd sops-git
    $ # Target to the needed tag (this is not tested):
    $ sed -i 's/branch=develop/branch=3.7.2/' PKGBUILD
    $ makepkg -si
    

The needed version was not in the cache, but I found it in the Arch Linux archive which was a good option. See the corresponding commands above.

References: