pkg icon indicating copy to clipboard operation
pkg copied to clipboard

'pkg which' attempts to write in the SQLite database

Open yurivict opened this issue 6 years ago • 3 comments

I got this error while running as a non-root user:

$ pkg which /usr/local/lib/libgltf-0.0.so
pkg: sqlite error while executing PRAGMA user_version; in file pkgdb.c:2443: attempt to write a readonly database

IMO, pkg which should be a read-only operation, it shouldn't attempt to write.

pkg-1.11.1 on FreeBSD 12 amd64

yurivict avatar Jul 14 '19 05:07 yurivict

pkg always try first to self upgrade its database. otherwise it might end up with a schema which is not valid and have commands failing with weird issue. if pkg which telles you it was to write, it is because the db schema has changed somehow. Meaning you need to run as root any pkg command.

yes it could probably be nicer about it and tell you 'hey your db is outdated upgrad it first' or something like that

bapt avatar Jul 14 '19 08:07 bapt

yes it could probably be nicer about it and tell you 'hey your db is outdated upgrad it first' or something like that

Yes, then the error message should say something like "The DB upgrade is needed but pkg doesn't have the write access to the file {file}, please run it as root once to upgrade the DB."

yurivict avatar Jul 14 '19 08:07 yurivict

Adding to that, I just got the same message when running "pkg info" on a /var/db/pkg directory on a snapshot directory.

Please add an '-f' or something when we are performing purely read operations. As it was, I had to copy the files to a temporary directory, and use that - just to read the dependency list of a package I'd just deleted!

Jamie-Landeg-Jones avatar Nov 19 '23 16:11 Jamie-Landeg-Jones