Query for available package versions with pacman
I am wondering if there is option to use pacman to query for available package versions.
If I want to install a specific version of a package I can do this by
pacman -S "bash>=3.2"
However, this requires that I already know what package versions are available. I would like to have something like this:
pacman -Q(?) bash
returning something like this:
> bash=3.2
> bash=3.1
> bash=3.0
> bash=2.0
If there isn’t an option via pacman, is this information available somewhere else?
Arch Linux is rolling-relase, mean it’s only provide the latest, so you can’t specify which version you want to download. However you can search and download the package manually from Arch Linux Archive at https://archive.archlinux.org/ then install manually
pacman -U package-name-0.0.0.tar.xz
Note that this method will not handle version conflicts, you need to change the version of dependencies by yourself.
Downgrade is a tool to downgrade (or select version you say it) one or multiple packages. You can also query available package version on your cache and Arch Linux Archive
Yudaka’s answer is the best answer to the question in response to the detail about package versioning, but it doesn’t answer the main question as framed by the question title about searching for package versions. I’m providing this answer for those that will come here as a result of the title, and I think this could be of some use to the OP as well.
Search for package versions
First I will just point out that man pacman
does say that a version specifier can be used when searching for packages:
You can also specify version requirements:
pacman -S "bash>=3.2"
.
Quotes are needed, otherwise the shell interprets ">" as redirection
to a file.
Presumably there may sometimes be multiple versions, like in circumstances where different versions of a package co-exist because they have significantly different functionality; such as Python 2 and Python 3. If only one version of that package is available in the database, then presumably the command will not install it if the version specifier excludes it.
Search for packages on the website
At the cost of being preachy, please consider searching on the website first. I know other package manager search functions have been depreciated and removed because the traffic volume from command line searches was too much. Especially consider not batching online search as automations can be unhelpful in increasing usage.
It’s certainly easy to remember the web address.
Online package search from command line
It’s not prominently documented, but pacman
can search for available packages: packages that haven’t been downloaded and installed yet, and it can do this with a regex:
pacman -Ss <regex>
E.g.:
pacman -Ss bash
There’s also a regex example in the man
page:
pacman -Ss ne.hack
Search for regexp "ne.hack" in package database.
Mnemonic for the -Ss
option
Pacman does have a "Q" for "query" command, but I believe that is restricted to querying installed packages only, and there’s a lot of flexibility and power there for managing your install base, finding orphans, and culling and pruning your packages and left over files.
This search is not a "query" because it targets the online database. It’s therefore a "sync" command: "S" for "sync". If you’ve come to terms with "syncing" when you’re installing hopefully you’ll have a flexible enough mind to put that in your memory when your command needs to reach out online, and then just remember that it’s the "s" option for "search": -Ss
: "Sync search".
How Good is pacman
?
Well, I dunno, but pacman
seems to have it all. There was no "no it can’t" answers in the whole scope. Pacman delivers. Power to the Arch.