Bug 206563 - ports-mgmt/pkg Incorrectly reads the index of installed packages.
Summary: ports-mgmt/pkg Incorrectly reads the index of installed packages.
Status: Closed Overcome By Events
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-pkg (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-24 11:16 UTC by Grzegorz Junka
Modified: 2018-01-12 14:13 UTC (History)
4 users (show)

See Also:
bugzilla: maintainer-feedback? (pkg)


Attachments
Output of pkg -vv (2.10 KB, text/plain)
2016-01-24 11:16 UTC, Grzegorz Junka
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Grzegorz Junka 2016-01-24 11:16:02 UTC
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.
Comment 1 Jason Unovitch freebsd_committer freebsd_triage 2016-01-24 15:28:44 UTC
`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).
Comment 2 Grzegorz Junka 2016-01-24 16:44:00 UTC
(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?
Comment 3 Jason Unovitch freebsd_committer freebsd_triage 2016-01-28 02:02:44 UTC
(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.
Comment 4 Grzegorz Junka 2016-01-28 08:07:27 UTC
(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.
Comment 5 Matthew Seaman freebsd_committer freebsd_triage 2016-01-28 09:40:05 UTC
(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.
Comment 6 Grzegorz Junka 2016-01-28 10:19:07 UTC
(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?
Comment 7 Walter Schwarzenfeld 2018-01-12 07:14:37 UTC
I think this is overcome by events.