I'm on macOS, and I am using haskell-ide-engine with lsp-mode/lsp-haskell in Emacs. I do not have a global ghc binary installed on my machine. I let stack install it locally in the project for each project. HIE is unable to find a ghc binary in the workspace. I had to put the ghc binary into the PATH to get it to work.
Thank you for the bug report!
Duplicate of #1495. Fix is in #1496.
This is also the case for me. Are users expected to have ghcup or something installed GHC locally? Is there a way to specify to HIE that I am using ghc installed through stack?
@drewboardman in your LSP client, invoke hie through stack exec hie and add a hie.yaml to project to explicitly state that you want to use stack to build your project. There should be a section in the README with an example of the hie.yaml
I tried this, and at least with emacs/lsp-haskell, this did not work. I
also modified the lsp-haskell elisp to be absolutely certain that the right
stack exec command was executed, and I got nothing but errors.
On Sat, Dec 28, 2019, 20:04 Luke Lau notifications@github.com wrote:
@drewboardman https://github.com/drewboardman in your LSP client,
invoke hie through stack exec hie and add a hie.yaml to project to
explicitly state that you want to use stack to build your project. There
should be a section in the README with an example of the hie.yaml—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/haskell/haskell-ide-engine/issues/1504?email_source=notifications&email_token=AALRLUPZYJLISRQNBGSBFVLQ3AAUFA5CNFSM4KARYFH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHYWABI#issuecomment-569466885,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AALRLULFCD7R5AIXSU6GSALQ3AAUFANCNFSM4KARYFHQ
.
@wraithm What errors did you get?
@drewboardman This should work as expected and is a bug that it does not work as expected. As said, this should be fixed in #1496 once it is merged.
Fixed by #1496, please try again
@fendor do we pull and re-install HIE?
Can you give a small explanation of how to check if it is fixed or not? Should I remove my ghcup binary of GHC from my path?
@bubba
in your LSP client, invoke hie through
stack exec hieand add ahie.yamlto project to explicitly state that you want to use stack to build your project. There should be a section in the README with an example of the hie.yaml
Using the following gets HIE working in most projects
"haskell": {
"command": "stack",
"args": ["exec", "hie-wrapper"],
However, when I add the recommended hie.yaml
# hie.yaml
cradle:
stack:
component: "haskell-ide-engine:lib"
I get the following error
[coc.nvim] CradleError (ExitFailure 1) ["Failed to parse result of calling stack","Error parsing targets: Unknown local package: haskell-ide-engine","Note that to specify options to be passed to GHCi, use the --ghci-options flag"]
Additionally, some projects still get the following error (described in this issue I opened):
@drewboardman Did you add this hie.yaml for haskell-ide-engine or for your personal project?
In the personal project, the component is rather <project>:lib. You can see the available targets via stack ide targets.
And yeah, you should pull from master and pull again. You can prove that it works if you have no ghc on the path, e.g.
ghc --version
Results in an error, and opening the project works.
@fendor Yep, pulling and using stack's ghc worked. I do have a question about the hie.yml and it's effectiveness. What does putting this in my project do, exactly? It's hard to tell from the readme.
Thank you for that feedback, if it is not clear, we must clarify that!
First, you can select how to build your project, either with stack or cabal.
Moreover, you can specify some stuff explicitly, e.g. that hie should not try to load certain files because they do not compile or are examples or something.
It also uses another mechanism to compile your project which may be desirable or not.
In general, you specify certain information, like paths to your components, in a way that hie understands them. It is more verbose, but you have more control about what is happening.
Interesting. So in the example with haskell-ide-engine:lib - is there a reason you would place your hie.yml in the hie directory, as opposed to your project? Or is that just for the example?
I am not sure what you mean.
It is intended that you put your hie.yaml (btw, I am pretty sure we are only looking for hie.yaml) in the root directory of the project, the same directory your stack.yaml or cabal.project is located.
In hie.yaml you specify which build tool to use and which path map to which component, e.g.
cradle:
stack:
component: "foo:lib"
Means that in the current directory, every haskell file is part of the library of the project foo.
You can extend that to multiple components, e.g. tests, benchmarks, executables with:
cradle:
stack:
- path: src/
component: "foo:lib"
- path: test/
component: "foo:test:unit-tests"
This is helpful, because tests and library can have different dependencies.
Most helpful comment
I am not sure what you mean.
It is intended that you put your
hie.yaml(btw, I am pretty sure we are only looking forhie.yaml) in the root directory of the project, the same directory yourstack.yamlorcabal.projectis located.In
hie.yamlyou specify which build tool to use and which path map to which component, e.g.Means that in the current directory, every haskell file is part of the library of the project
foo.You can extend that to multiple components, e.g. tests, benchmarks, executables with:
This is helpful, because tests and library can have different dependencies.