ndmitchell / ghcid

Very low feature GHCi based IDE
Other
1.13k stars 114 forks source link

Do not break on `-Wunused-packages` #356

Open LennartSpitzner opened 2 years ago

LennartSpitzner commented 2 years ago

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.

jumper149 commented 2 years ago

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.

ndmitchell commented 2 years ago

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!