Hello,


I'd like to know how ghc-pkg searches package databases and how the command-line flags affect the search.


My model of ghc-pkg was that it builds a list of package databases and then searches them starting from the head.  I'd like to work with a sandboxed local package database.  Looking at what ghc-pkg list prints, I can infer what database list it's using:


ghc-pkg list: [user-db, global-db]


ghc-pkg list --global: [global-db]


ghc-pkg list --global --package-conf=$HOME/sandbox/package.conf.d: [sandbox-db, global-db]


However, even though ghc-pkg doesn't show my user database, it still reports broken packages that are in my user database.  So ghc-pkg isn't really scanning packages according to this database list.  What is it doing?