haskell / haskell-ide-engine

The engine for haskell ide-integration. Not an IDE
BSD 3-Clause "New" or "Revised" License
2.38k stars 212 forks source link

Ghc error on cradle initialisation: "cannot satisfy -package-id ... #1682

Closed mrkafk closed 4 years ago

mrkafk commented 4 years ago

When opening project https://github.com/mrkafk/helloworld in VSCode, I keep getting errors like in title. HIE log below.

My settings.json:

"languageServerHaskell.logFile": "/tmp/hie.log",
"languageServerHaskell.hieExecutablePath": "/home/user/.local/bin/hie-8.6.5",
"languageServerHaskell.liquidOn": true,
"haskell.hlint.executablePath": "/home/user/.local/bin/hlint"

HIE log:

2020-03-05 17:58:04.712030202 [ThreadId 4] - Run entered for HIE(hie-8.6.5) Version 1.1, Git revision 6afa461899c2c5d448fd1b452c2f8b4c3883e917 (3769 commits) x86_64 ghc-8.6.5
2020-03-05 17:58:04.712361243 [ThreadId 4] - Operating as a LSP server on stdio
2020-03-05 17:58:04.712420243 [ThreadId 4] - Current directory:/home/user/haskell/helloworld
2020-03-05 17:58:04.712467367 [ThreadId 4] - Operating system:linux
2020-03-05 17:58:04.712520867 [ThreadId 4] - args:["--lsp","-l","/tmp/hie.log"]
2020-03-05 17:58:04.745837661 [ThreadId 4] - Cabal-Helper decided to use: ProjLocStackYaml {plStackYaml = "/home/user/haskell/helloworld/stack.yaml"}
2020-03-05 17:58:05.938937635 [ThreadId 4] - Module "/home/user/haskell/helloworld/File.hs" is loaded by Cradle: Cradle {cradleRootDir = "/home/user/haskell/helloworld", cradleOptsProg = CradleAction: Other Stack}
2020-03-05 17:58:05.939238801 [ThreadId 4] - Executing Stack GHC with args: --numeric-version
2020-03-05 17:58:06.192089701 [ThreadId 29] - Executing Stack GHC with args: --print-libdir
2020-03-05 17:58:06.49746245 [ThreadId 34] - New cradle: /home/user/haskell/helloworld/app/Main.hs
2020-03-05 17:58:06.498397613 [ThreadId 34] - Cabal-Helper decided to use: ProjLocStackYaml {plStackYaml = "/home/user/haskell/helloworld/stack.yaml"}
2020-03-05 17:58:07.677604889 [ThreadId 34] - Module "/home/user/haskell/helloworld/app/Main.hs" is loaded by Cradle: Cradle {cradleRootDir = "/home/user/haskell/helloworld", cradleOptsProg = CradleAction: Other Stack}
2020-03-05 17:58:07.677781805 [ThreadId 34] - Found cradle: Cradle {cradleRootDir = "/home/user/haskell/helloworld", cradleOptsProg = CradleAction: Other Stack}
2020-03-05 17:58:08.819239136 [ThreadId 60] - Ghc error on cradle initialisation: "cannot satisfy -package-id helloworld-0.1.0.0-5AFk17aNCLW4CrcpWxCXgp\n    (use -v for more information)"
2020-03-05 17:58:08.819372302 [ThreadId 34] - ghcDispatcher:Got error for a request: IdeError {ideCode = OtherError, ideMessage = "\"cannot satisfy -package-id helloworld-0.1.0.0-5AFk17aNCLW4CrcpWxCXgp\\n    (use -v for more information)\"", ideInfo = Null} with mid: Nothing
2020-03-05 17:58:08.819537801 [ThreadId 34] - New cradle: /home/user/haskell/helloworld/app/Main.hs
2020-03-05 17:58:08.820886213 [ThreadId 34] - Cabal-Helper decided to use: ProjLocStackYaml {plStackYaml = "/home/user/haskell/helloworld/stack.yaml"}
2020-03-05 17:58:10.020385789 [ThreadId 34] - Module "/home/user/haskell/helloworld/app/Main.hs" is loaded by Cradle: Cradle {cradleRootDir = "/home/user/haskell/helloworld", cradleOptsProg = CradleAction: Other Stack}
2020-03-05 17:58:10.020576205 [ThreadId 34] - Found cradle: Cradle {cradleRootDir = "/home/user/haskell/helloworld", cradleOptsProg = CradleAction: Other Stack}
2020-03-05 17:58:10.419253859 [ThreadId 88] - Ghc error on cradle initialisation: "cannot satisfy -package-id helloworld-0.1.0.0-5AFk17aNCLW4CrcpWxCXgp\n    (use -v for more information)"
2020-03-05 17:58:10.419462234 [ThreadId 34] - ghcDispatcher:Got error for a request: IdeError {ideCode = OtherError, ideMessage = "\"cannot satisfy -package-id helloworld-0.1.0.0-5AFk17aNCLW4CrcpWxCXgp\\n    (use -v for more information)\"", ideInfo = Null} with mid: Nothing

stack clean and stack build do not help.

jneira commented 4 years ago

Hi! Your package.yaml states the lib modules should be inside the src subdir but i dont see Lib.hs in the log. Maybe you need to add a exposed-modules field in the library section? Does stack build work without errors?

mrkafk commented 4 years ago

stack build runs without problems. The program executes. I still get the error.

mrkafk commented 4 years ago

P.S. I created the project by stack new helloworld new-template. After that I just adjusted stack.yaml with resolver: lts-14.2.

fendor commented 4 years ago

Unfortunately, that is a known error, duplicate of #1608 Sorry, you are running into this. Work around: provide a custom hie.yaml. In your particular case,

cradle:
  stack:

Should suffice. For more complex hie.yaml configurations take a look at https://github.com/haskell/haskell-ide-engine/#project-configuration

jneira commented 4 years ago

Well, in my case i've reproduced the error at first but after a stack build and restart vscode, hie loads the app/Main.hs correctly. The behaviour is reproducible:

fendor commented 4 years ago

Yeah, it is on and off. I think somewhere we found a semi reproducible set of steps. But it is definitely related to cabal-helper and stack.

jneira commented 4 years ago

@mrkafk did you experience that behaviour? in my case after running stack build and restarting hie, the Main.hs file is loaded succesfully

mrkafk commented 4 years ago

Hello Javier,

Thank you for looking into this problem!

Anyway, I reproduced your steps and it worked indeed. At first.

Then I started writing another function in Main.hs and the weird thing happened: while autocompletion works, e.g. when starting to type "put.." (StrLn autocompletion popping up), now the same original error keeps popping up. This does not prevent HIE from working however, at least in basic sense.

mrkafk commented 4 years ago

@fendor Your workaround works fine. Thank you!

jneira commented 4 years ago

@mrkafk ok, so i'll close this one if you dont mind and we will tracking this in #1608