4

opam list -a lists all packages currently available at OPAM, but does not display the version number for packages which are not currently installed, as per the opam list --help output:

(...) the output format displays one package per line, and each line contains the name of the package, the installed version or -- if the package is not installed, (...)

How can I list all packages including their version numbers?

anol
  • 8,264
  • 3
  • 34
  • 78

3 Answers3

5

Use opam info <packagename>.

I guess opam list does only prints the versions of already installed packages because of the package dependencies. Listing the latest versions of packages, for example, of not-yet-installed packages is not quite useful.

camlspotter
  • 8,990
  • 23
  • 27
  • The issue with `opam info` is that it only accepts one package at a time, for instance if I want to quickly see the latest versions of every `mirage*` package, I have to list all of them and then individually query for each version. – anol Oct 13 '15 at 11:25
2

A refined (and quicker) version of anol's answer is to give the whole list of packages to opam show in one pass (asking opam to output both package and version field), and to process the result with sed, as apparently show outputs each field on its own line:

opam show -f package,version $(opam list -a -s) \
 | sed -e '/ *package:/N; s/ *package: \([^\n]*\)\n *version: \([^\n]*\)/\1: \2/'
Virgile
  • 9,724
  • 18
  • 42
1

This is not an ideal solution, but using camlspotter's recommandation, I manually queried each package for its version field, using the following shell loop:

for p in $(opam list -a -s); do echo "$p $(opam show -f version $p)"; done

It works, but it takes ~85 seconds to complete on my machine (querying over 1000 packages currently available).

anol
  • 8,264
  • 3
  • 34
  • 78