ghc-pkg recache only recaches a single package database
I've put together a minimal repro of the problem we encountered, I'll give the backstory at the bottom.
The short version is: the ghc-pkg recache command does not clarify in its documentation which package databases it will perform a recache on. In reality, it appears to only perform the recache on the top database in the stack (whether using GHC_PACKAGE_PATH or the --package-db command line flags). Warnings which recommend "run ghc-pkg recache" will not be resolved by running that command, at least without providing different arguments/env vars.
Some possible resolutions:
- Modify the behavior of
recacheto recache all package databases. Possible modifications: do not attempt to recache the global database, do not attempt to recache up-to-date databases, do not fail on permission denied errors. - Modify the usage documentation for
recacheand error messages for theghc-pkg recachecommand to clarify that only a single database is modified byrecache - Provide a warning when calling
recachewith multiple databases
Use case
I was debugging an issue with a CI system, where two different forms of caching of binary artifacts were at play. An older version of package.cache ended up stomping on the newer package.cache, making some packages appear to sometimes not be available, leading to confusing error messages. I noticed the ghc-pkg recache warning coming from ghc-pkg list, and we added a ghc-pkg recache call to the CI scripts. This ended up doing nothing, while deleting the package.cache file completely did resolve the issue.
Separately from the above, we need to fix the CI scripts, but it does seem like the recache behavior could be a bit more intuitive.