Allow multiple cradle types
Closed this issue · 3 comments
I have one project which I sometimes develop using Stack and sometimes develop using Cabal. Accordingly my hie.yaml
looks something like this:
cradle:
stack:
# …
cabal:
# …
However, I discovered that this only allows development with Cabal. Even when developing on a machine where only Stack is installed globally, HLS still prefers to use the Cabal cradle, which of course causes an error.
The issue arises from this point in HIE.Bios.Config
:
hie-bios/src/HIE/Bios/Config.hs
Lines 158 to 161 in df7c429
Obviously, if hie.yaml
contains a Cabal cradle, the first guard will be satisfied even if another cradle would be better. To me, it seems that the easiest solution would be to return every possible cradle from parseCradleType
(so make it a Parser (NonEmpty (CradleType a))
), then filter them down to one cradle by testing for existence of the relevant executables. Are there any problems with this? If not, I will submit a PR.
Hi, thanks for open the issue. That automatic discovery using executables in scope and build dirs existence (like .stack-work or dist-newstyle) is implemented in implicit-hie:
For now that closed to build tools checks were not included here, but it means you have to rely in the implicit cradle to switch automatically between tools. That is the recommended way to use hls for example, does not the implicit cradle works for you for some reason?
[
implicit-hie
] is the recommended way to use hls
I didn’t know this was the case, thanks for clarifying! When I started using HLS, the advice was to use an explicit cradle… has this changed recently?
Even so, does this issue still need to be fixed? Or should it be left as-is?
I didn’t know this was the case, thanks for clarifying! When I started using HLS, the advice was to use an explicit cradle… has this changed recently?
We removed the alert in vscode time ago and demoted it to a warning, noting what is the precise error (pretty rare btw) which can be fixed using a explicit hie.yaml file. We changed the official docs to state it but several internet sources still recommends it.
Even so, does this issue still need to be fixed? Or should it be left as-is?
I would say that the way to go would be using the implicit cradle and avoid duplicate the logic here. If anyone really needs a explicit hie.yaml and change the build tool frequently (not very common situation?) they could have both hie-cabal.yaml and hie-stack.yaml and change the default one with scripting.