Open brandonchinn178 opened 1 year ago
I don't know if/how this could be fixed in cabal. Its really an issue with the "purpose" of cabal exec, combined with the nature of what ghc flags do. Cabal exec needs to construct an environment file that has all packages in the closure of what the specified deps are, by design. However, that's going to be a superset of the packages literally depended on directly by a package. So when build is invoked in this environment, there will necessarily be additional packages available beyond those a package makes use of directly, and the heuristics of -Wunused-packages will correctly notice this.
I feel like its potentially more a ghc/upstream issue -- in particular ghc should warn about unused packages passed as package-id flags, but not those that are actually provided in an envfile but then treated as though they were passed as such flags...
Describe the bug When
-Wunused-packages
is enabled, building or running tests withcabal exec
errors with all dependencies being used.To Reproduce Steps to reproduce the behavior:
This results in
Expected behavior
cabal v2-build
andcabal exec cabal v2-build
should behave the same.System information
Additional context Add any other context about the problem here.