Solved pkg (pkgng) reports all packages orphaned

On my pretty fresh install (10.1-RELEASE) I never used anything else than pkgng. It was working great until today.

Now, suddenly, pkg version reports all packages as "orphaned".

I have found "pkg version reports every package as orphaned when run from non-existant directory" [1] but I am running the pkg command from let's say /root.

Can anyone point me in the right direction to resolve this? I know what packages I have installed, so if this is the only option I could also run "pkg install" for all of them again. But I am not sure if that would even solve the problem...

[1] https://github.com/freebsd/pkg/issues/773
 
Are you using your own repository? Can you post the output of pkg -vv?

If pkg(8) cannot find the package on the repository it will show up as 'orphaned'.
 
Thank you very much for answering. Let's see if I can get the required information.

I am not using a custom repository.

This is the output of pkg -vv:

Code:
# pkg -vv
Version                 : 1.5.6
PKG_DBDIR = "/var/db/pkg";
PKG_CACHEDIR = "/var/cache/pkg";
PORTSDIR = "/usr/ports";
INDEXDIR = "";
INDEXFILE = "INDEX-10";
HANDLE_RC_SCRIPTS = false;
DEFAULT_ALWAYS_YES = false;
ASSUME_ALWAYS_YES = false;
REPOS_DIR [
    "/etc/pkg/",
    "/usr/local/etc/pkg/repos/",
]
PLIST_KEYWORDS_DIR = "";
SYSLOG = true;
ABI = "FreeBSD:10:amd64";
ALTABI = "freebsd:10:x86:64";
DEVELOPER_MODE = false;
VULNXML_SITE = "http://vuxml.freebsd.org/freebsd/vuln.xml.bz2";
FETCH_RETRY = 3;
PKG_PLUGINS_DIR = "/usr/local/lib/pkg/";
PKG_ENABLE_PLUGINS = true;
PLUGINS [
]
DEBUG_SCRIPTS = false;
PLUGINS_CONF_DIR = "/usr/local/etc/pkg/";
PERMISSIVE = false;
REPO_AUTOUPDATE = true;
NAMESERVER = "";
HTTP_USER_AGENT = "pkg/1.5.6";
EVENT_PIPE = "";
FETCH_TIMEOUT = 30;
UNSET_TIMESTAMP = false;
SSH_RESTRICT_DIR = "";
PKG_ENV {
}
PKG_SSH_ARGS = "";
DEBUG_LEVEL = 0;
ALIAS {
    all-depends = "query %dn-%dv";
    annotations = "info -A";
    build-depends = "info -qd";
    cinfo = "info -Cx";
    comment = "query -i \"%c\"";
    csearch = "search -Cx";
    desc = "query -i \"%e\"";
    download = "fetch";
    iinfo = "info -ix";
    isearch = "search -ix";
    prime-list = "query -e '%a = 0' '%n'";
    leaf = "query -e '%#r == 0' '%n-%v'";
    list = "info -ql";
    noauto = "query -e '%a == 0' '%n-%v'";
    options = "query -i \"%n - %Ok: %Ov\"";
    origin = "info -qo";
    provided-depends = "info -qb";
    raw = "info -R";
    required-depends = "info -qr";
    roptions = "rquery -i \"%n - %Ok: %Ov\"";
    shared-depends = "info -qB";
    show = "info -f -k";
    size = "info -sq";
}
CUDF_SOLVER = "";
SAT_SOLVER = "";
RUN_SCRIPTS = true;
CASE_SENSITIVE_MATCH = false;
LOCK_WAIT = 1;
LOCK_RETRIES = 5;
SQLITE_PROFILE = false;
WORKERS_COUNT = 0;
READ_LOCK = false;
PLIST_ACCEPT_DIRECTORIES = false;
IP_VERSION = 0;
AUTOMERGE = true;
VERSION_SOURCE = "";
CONSERVATIVE_UPGRADE = true;
PKG_CREATE_VERBOSE = false;
AUTOCLEAN = false;


Repositories:
  FreeBSD: {
    url             : "pkg+http://pkg.FreeBSD.org/FreeBSD:10:amd64/latest",
    enabled         : yes,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }

I have also checked /var/db/pkg/local.sqlite and was very pleased that the information seems to be there (I feared that I had lost the database).

Code:
sqlite>.mode column
sqlite>.headers on
sqlite> select id, origin, name, automatic, locked, datetime(time,'unixepoch'), pkg_format_version from packages where automatic = 0;
id          origin           name        automatic   locked      datetime(time,'unixepoch')  pkg_format_version
----------  ---------------  ----------  ----------  ----------  --------------------------  ------------------
95          sysutils/screen  screen      0           0           2015-08-06 22:39:20
98          devel/p5-Config  p5-Config-  0           0           2015-08-10 14:20:43
99          net-mgmt/p5-Net  p5-Net-IP   0           0           2015-08-10 14:21:22
100         net-mgmt/p5-Net  p5-NetAddr  0           0           2015-08-10 14:21:54
102         net/p5-Net-Addr  p5-Net-Add  0           0           2015-08-10 14:23:36
107         dns/p5-Net-DNS   p5-Net-DNS  0           0           2015-08-10 14:24:17
109         lang/p5-Try-Tin  p5-Try-Tin  0           0           2015-08-10 14:25:49
115         net-mgmt/p5-Net  p5-Net-SNM  0           0           2015-08-10 14:26:21
117         databases/p5-RR  p5-RRD-Sim  0           0           2015-08-10 14:26:57
119         devel/p5-RRDToo  p5-RRDTool  0           0           2015-08-10 14:27:20
120         databases/p5-DB  p5-DBD-mys  0           0           2015-08-10 14:28:24
121         net-mgmt/net-sn  net-snmp    0           0           2015-08-13 14:44:03
122         ports-mgmt/pkg   pkg         0           0           2015-08-15 18:19:17
123         net/isc-dhcp43-  isc-dhcp43  0           0           2015-08-15 18:20:07
125         dns/bind910      bind910     0           0           2015-08-15 19:03:12
152         editors/vim      vim         0           0           2015-08-28 22:44:58
153         databases/p5-DB  p5-DBI      0           0           2015-08-28 22:45:03
154         databases/mysql  mysql56-se  0           0           2015-08-28 22:45:03
155         shells/bash      bash        0           0           2015-08-28 22:45:08
161         security/gnupg   gnupg       0           0           2015-09-04 20:38:45
186         security/p5-Gnu  p5-GnuPG-I  0           0           2015-09-04 21:19:45
212         www/p5-HTTP-DAV  p5-HTTP-DA  0           0           2015-09-04 21:20:30
213         www/p5-LWP-Prot  p5-LWP-Pro  0           0           2015-09-04 21:32:35
214         security/sudo    sudo        0           0           2015-09-05 16:26:33
215         www/lighttpd     lighttpd    0           0           2015-09-05 20:55:22
216         mail/postfix-cu  postfix-cu  0           0           2015-09-05 22:10:21
217         mail/dovecot     dovecot     0           0           2015-09-05 22:29:39
218         ftp/curl         curl        0           0           2015-09-07 15:29:09
219         devel/p5-Term-R  p5-Term-Re  0           0           2015-09-07 20:22:17
 
Thanks! That did the trick. And easy it was...

Still, I don't understand what happened.

Code:
$ pkg update -f
Updating FreeBSD repository catalogue...
Fetching meta.txz: 100%    944 B   0.9kB/s    00:01
Fetching packagesite.txz: 100%    5 MiB   1.1MB/s    00:05
Processing entries: 100%
FreeBSD repository update completed. 24553 packages processed.
$ pkg version -vL "=" |wc -l
      15
 
Back
Top