haskell-ide-engine icon indicating copy to clipboard operation
haskell-ide-engine copied to clipboard

Improve behaviour handling a module when a component on which it depends has errors

Open jneira opened this issue 5 years ago • 5 comments
trafficstars

  • Common case: a module of the main library has a compilation error but you are working on the exe (or test) component which has no errors
  • Actually master handles nicely this case (with stack based projects):
    • it shows the concrete error of the lib component file in the problems tab as you had opened it in first place.
    • you can simple click the error and it opens the file to fix the error
  • hie-bios instead cant initialize the cradle and the editor shows an error alert with an obscure message for common users:
    • CradleError (ExitFailure 2) "Could not obtain flags for D:\\ws\\haskell\\cabal-test\\src\\Main.hs" using the cradle Cabal-Helper-Cabal-V2
    • "cannot satisfy -package-id stack-test-0.1.0.0-73xUn6TuFvs4BD1QAaTRw6\n (use -v for more information)" using Cabal-Helper-Stack

Ideally we should recover the master behaviour for stack to improve user experience. At least the error message should be related to the original error as closely as possible, including the file or files where they are

(moved from https://github.com/mpickering/haskell-ide-engine/issues/66)

jneira avatar Dec 23 '19 20:12 jneira

Tested this out, only happens on the cabal-helper cradles during https://github.com/haskell/haskell-ide-engine/blob/7e688322a40d91369bd032ea4be977fa405dc41f/hie-plugin-api/Haskell/Ide/Engine/Cradle.hs#L443-L462

Attached test case, remove hie.yaml to see it fail

comperrortest.zip

lukel97 avatar Dec 24 '19 03:12 lukel97

After some research, it comes down to the fact that in order to get the flags for each component inside a unit, cabal-helper runs cabal build --only-configure foo. Which actually builds all the dependencies, but configures foo. Changing this to cabal configure foo doesn't build the dependencies, but it then doesn't create the component dist-dir, which contains the files needed for cabal-helper to pull out the ghc flags.

lukel97 avatar Dec 28 '19 22:12 lukel97

Does ghcide handle this or is it also crippled?

I seem to recall ghcide parsing module imports independently starting from open files?

Avi-D-coder avatar Dec 28 '19 23:12 Avi-D-coder

@Avi-D-coder hie-bios handles it ok when there is an explicit cradle set in hie.yaml, this only happens when getting flags via cabal-helper

lukel97 avatar Dec 29 '19 01:12 lukel97

#1596 is related to this but applied to hie-bios.

fendor avatar Jan 24 '20 11:01 fendor