ghcid icon indicating copy to clipboard operation
ghcid copied to clipboard

Do not break on `-Wunused-packages`

Open LennartSpitzner opened this issue 2 years ago • 2 comments

If you start a ghci session is started with "unused-packages" warning enabled you can get output like this:

<no location info>: warning: [-Wunused-packages]
    The following packages were specified via -package or -package-id flags,
    but were not needed for compilation:
      - foo-0.2.0.0
      - bar-1.0.0.1

~at the end of loading iirc~ before it start compiling the first module. This seems to break ghcid, which, on first load, reports errors as expected, but then hangs on the first reload. Of course fixing the warning (removing foo/bar or disabling the warning if your setup just adds spurious -packages) is the obvious fix, but it might be worth making ghcid more robust, as just hanging without any error output is annoying to debug.

I guess this would need an addition to https://github.com/ndmitchell/ghcid/blob/master/src/Language/Haskell/Ghcid/Parser.hs#L60, right? Or would it be better (for now) to just force the warning off for the time being (by insert a :set into the ghci session)

Do you think it is worth fixing this? Suggestion on best approach?

This happens for us on a slightly larger project; I somewhat assume it is easy to reproduce, but if it is not I can of course come up with a sample project setup for reproduction.

LennartSpitzner avatar Mar 15 '22 15:03 LennartSpitzner

I'm experiencing the same.

Actually the same warning is also printed with cabal repl. So maybe this problem should be addressed there (in GHCi or cabal, idk)? cabal build works as expected at least :)

This also falls into the same category as #358.

jumper149 avatar Mar 18 '22 13:03 jumper149

I think the right solution is to adjust the parser to take account of this warning. Unconditionally disabling warnings is a bit annoying because it varies between GHC version, they can be set later on in the process, and you also lose warnings that are presumably useful. PR welcome!

ndmitchell avatar Mar 26 '22 11:03 ndmitchell