-
Notifications
You must be signed in to change notification settings - Fork 691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect unused packages with new-build #5331
Comments
I for one would like to see this. Even though I like the Unix approach of one tool for one task, having this in cabal without the need for a secondary tool would get a lot more usage than what wieder or packunused get today. I would also argue we have precedence for this in cabal already with the missing module listing warnings. |
prior ticket on this: #1820 i'd be all for this. |
Fwiw, it was always the plan for me to eventually integrate |
I think we can teach GHC to warn about unused dependencies. It already has everything on hands to do the check. GHC loads modules lazyly, so at the end of compilation it has a list of actually used packages, see |
@Yuras I'd like to have such a warning in GHC but I don't think this is future-proof if I understand your suggestion correctly as it relies on using That being said, if it's a simple patch, I'd strongly suggest to implement it and try it; it may serve as a very useful short-term stopgap solution which I'd love to use if it works. |
@hvr I made a patch, see https://ghc.haskell.org/trac/ghc/ticket/15838 |
@hvr The approach I described doesn't work for indirect dependencies. Simply because they are actually required for compilation. E.g. if we specify |
I'm in favor of this. PR's welcome, and I'm available for review. |
https://downloads.haskell.org/ghc/latest/docs/html/users_guide/using-warnings.html#ghc-flag--Wunused-packages, i.e. having
should work |
This modern technology is astounding. So what do we do? Dear issue participants, can you verify this works as required and recommend the closure of this issue? |
@Mikolaj The |
It also is very confusing output, because there is no location info and it just dumps several checks for every library and executable you have. And when you have a compilation failure, the output is outright wrong. I also have the impression I get incorrect suggestions when using if-conditions in cabal. So after trying this for half an hour, I gave up. |
Is there a GHC ticket about that? |
@hasufell Sorry for your bad experience with this flag. Let's see what we can improve there.
Yep. The warning is about command line options, so there is no location. And GHC doesn't know anything about cabal file.
That might be cabal issue. E.g. it's running GHC multiple times (compilation and linking), and AFAIK there is no way in cabal to specify GHC options only for compilation run.
I guess it should be possible to suppress it in that case. But why do you care about this warning in case of build failure? I mean, just ignore it's output.
It might be cabal issue. Could you please check whether cabal runs GHC with the conditioned-out dependencies? |
IMO it’d be strange for cabal to reimplement and maintain a feature that is already available in GHC albeit with a suboptimal UI. The right direction would be to improve the GHC feature rather than duplicate. |
No objections, so optimistically closing. Feel free to reopen if disagree. |
I would like
cabal
to support detection of redundant packages withcabal new-build
, likeweeder
orpackunused
. This would entail:.cabal
filecabal.project
files to toggle detection of redundant packagesI can do all of the work, but I would like to know that this is a welcome feature before getting started.
The text was updated successfully, but these errors were encountered: