I'm trying to use pkg search on FreeBSD to search for "known packages" in the configured repos. The existing code uses pkg search -R <format_args> all to query remote repos and update the local catalog copy, then return raw info on all packages.

The problem is that this works fine if the repo is available. But if the remote repo isn't available (DNS issues, no internet, whatever) then the local copy is removed too, so whatever info could have been obtained from the local catalog copy (even if one or two packages out of date) is lost until online contact is next made with the remote repo. This means that after repo access failure, any kind of offline activity requiring a search of the local catalog will be impossible.

The only options I can find that don't imply clearing the local copy on failure are -U (which simply prevents any update that might have been available from being attempted whether or not it would have succeeded), and pkg info (which provides local installed pkg data and doesn't provide repo copy catalog data); neither seem helpful.

Is there a way I can use pkg that updates the catalog copy beforehand as usual, iff a valid update can be obtained, but doesn't wipe it if it can't?

1 Answer 1


Edit your pkg.conf and set REPO_AUTOUPDATE to NO as mentioned on the man pkg search :

Package repository  catalogues will be automatically updated whenever pkg
 search is run by a user ID with write access to the package database,
 unless disabled by the -U flag or setting REPO_AUTOUPDATE to NO in
  • That doesn't seem to solve the question. It looks like it just does the same as -U, completely disables updating. What I'm trying to do is update the local copy if the external repo can be read, without also wiping the local copy if the attempt fails.
    – Stilez
    Jan 19, 2017 at 8:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .