Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

HIE unable to find ghc binary for stack project #1504

Closed
wraithm opened this issue Dec 28, 2019 · 13 comments
Closed

HIE unable to find ghc binary for stack project #1504

wraithm opened this issue Dec 28, 2019 · 13 comments

Comments

@wraithm
Copy link

wraithm commented Dec 28, 2019

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.

@fendor
Copy link
Collaborator

fendor commented Dec 28, 2019

Thank you for the bug report!
Duplicate of #1495. Fix is in #1496.

@drewboardman
Copy link

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?

@lukel97
Copy link
Collaborator

lukel97 commented Dec 29, 2019

@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

@wraithm
Copy link
Author

wraithm commented Dec 29, 2019 via email

@fendor
Copy link
Collaborator

fendor commented Dec 29, 2019

@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.

@fendor
Copy link
Collaborator

fendor commented Dec 29, 2019

Fixed by #1496, please try again

@fendor fendor closed this as completed Dec 29, 2019
@drewboardman
Copy link

@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?

@drewboardman
Copy link

drewboardman commented Dec 29, 2019

@bubba

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

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):

#1508

@fendor
Copy link
Collaborator

fendor commented Dec 29, 2019

@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.

@drewboardman
Copy link

@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.

@fendor
Copy link
Collaborator

fendor commented Dec 29, 2019

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.

@drewboardman
Copy link

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?

@fendor
Copy link
Collaborator

fendor commented Dec 29, 2019

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants