$ cabal install doctest --overwrite-policy=always && cabal exec -- doctest -isrc dump-decls-lib/src/
Warning: The package list for 'hackage.haskell.org' is 73 days old.
Run 'cabal update' to get the latest list of available packages.
Warning: The package list for 'hackage.haskell.org' is 73 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
Symlinking 'doctest' to '/Users/rune/.cabal/bin/doctest'
Warning: The package list for 'hackage.haskell.org' is 73 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
doctest: Missing file: /nix/store/g1w99d0b9628lvwbyljm7hgrlnw5zc0n-ghc-9.6.2/lib/ghc-9.6.2/lib/settings
 
I think the problem is that ghc-paths was compiled with one version of GHC in the PATH and now that version of GHC is no longer present where it was before. This happens because ghc-paths' path to ghc is fixed at compile-time of ghc-paths.
This is perhaps a duplicate of #40. But that issue was closed, pointing to #42 for the reason, in which a comment mentions a workaround that I can't find. What's the workaround?