Created attachment 166050 [details] Output of pkg -vv According to pkg help: info Displays information about installed packages version Displays the versions of installed packages So they both produce information about installed packages. Please note that info outputs more information than version, so should be more prone to corrupt data. However, pkg info does work correctly: root@crayon2:~ # pkg info CharisSIL-4.114_1 Charis SIL TrueType font collection CoinMP-1.8.3 Optimization library with support for COIN-OR CLP, CBC, and CGL DoulosSIL-4.112_1 Doulos SIL TrueType font collection GentiumBasic-110_3 Gentium Basic and Gentium Book Basic TrueType fonts GeoIP-1.6.9 Find the country that any IP address or hostname originates from GraphicsMagick-1.3.23_2,1 Fast image processing tools based on ImageMagick (...) where pkg version fails: root@crayon2:~ # pkg version pkg: No valid entries found in '/usr/ports/INDEX-10' It looks like they are reading the information about installed packages from different places and pkg version fails when the port index is corrupted.
`pkg version -R' will give what you expect. The behaviour is documented in the pkg-version(8) man page: The database of available packages and versions to compare against the installed packages may be chosen by specifying one of -P, -R or -I or by by setting VERSION_SOURCE in pkg.conf(5). If not specified then the ports index file will be used if it exists (-I). Otherwise, should a ports tree exist that will be used to compare versions (-P). Failing either of those two choices, the repository catalogue will be used (-R).
(In reply to Jason Unovitch from comment #1) Fair enough. Is the default then wrong? Why would 'pkg version' and 'pkg info' compare to different sources by default?
(In reply to Grzegorz Junka from comment #2) Well this is going to be a pkg@ person's final call but 'version' != 'info'. 'info' won't show if packages are older/newer like 'version' does and per pkg-info(8) there is a large amount of what can be displayed about local packages that pkg-version(8) does not show.
(In reply to Jason Unovitch from comment #3) I fixed this issue by deleting the whole /usr/ports tree, which suggests that it's not essential for the command to work. And its defaulting to the port index is quite annoying when the index becomes corrupted, something quite easy to do by accident by selecting options that introduce a circular dependency.
(In reply to Grzegorz Junka from comment #4) So, why don't you use one of the -P, -I or -R options to pkg version so you can control exactly where pkg gets its version info from? You could also set VERSION_SOURCE in pkg.conf if you prefer.
(In reply to Matthew Seaman from comment #5) Because I am an average user and I didn't know pkg is reading information from different sources unless you configure it to not to. As I said, this is fixed for me now because I deleted the whole ports tree, however I still think it's confusing to the user. Do you expect them to know the inner workings of pkg and read the whole documentation to be able to figure out how to execute 'pkg version' when the index is corrupted? Not even mentioning the fact that pkg is for binary package management and should not be tied up to ports sources?
I think this is overcome by events.