rikvdkleij / intellij-haskell

IntelliJ plugin for Haskell
https://rikvdkleij.github.io/intellij-haskell/
Apache License 2.0
1.31k stars 94 forks source link

Be able to use the `stack` executable in path #570

Closed sir4ur0n closed 4 years ago

sir4ur0n commented 4 years ago

Hi,

In the same spirit as https://github.com/rikvdkleij/intellij-haskell/issues/485 could the intellij-haskell plugin use the stack executable in path? Or at least make it possible!

This is for the same reason of using Nix (in my case, we package a custom Stack executable where Nix options are all passed). Currently I have to configure an ugly path like /nix/store/g14h563bs6r1s9vrd1dgrald6pg2895q-stack/bin/stack, but this path may change whenever I change some configuration in my stack wrapper...

AFAICT this would be the last bit to have a better support for Nix with Intellij :sweat_smile:

Cheers!

rikvdkleij commented 4 years ago

I will give it a try soon.

davnn commented 4 years ago

Would probably also solve path problems in Windows (https://github.com/rikvdkleij/intellij-haskell/issues/557).

rikvdkleij commented 4 years ago

I have given it a try but without success for now. The current way of setting up a Sdk does not support using an exe on the PATH. I have asked for some support on the Jetbrains Slack channel.

Alternative solution could be to just skip creating a Sdk when stack is on the PATH.... But that will mean that users have no choice anymore, when stack is on the PATH that one will be (implicitly) chosen.

sir4ur0n commented 4 years ago

Isn't it possible to setup an SDK with no path? E.g. with a checkbox "Use path". That would create an SDK with no path, and if it's used for a project, then look for Stack in path instead?

rikvdkleij commented 4 years ago

No, i'm constrained by how the IntelliJ SDK is working. Probably there is some way but that would be a completely custom solution and i don't know how to hook that into the IntelliJ SDK.

The "default" way expects a real absolute path and no way to edit it later. Tried different workarounds and went through the IntelliJ SDK code...

It's really tightly coupled code with no way to change in a way we want. So I asked for help.

rikvdkleij commented 4 years ago

The only solution which i can implement is to create in Haskell Settings an flag which indicates to use the stack exe in path (with some validation). So this is a workaround. It will ignore the stack path in Haskell Stack SDK.

sir4ur0n commented 4 years ago

Still sounds good to me!

rikvdkleij commented 4 years ago

Ok, other solution which is more consistent, is to remove the Haskell stack SDK and make stack as executable on the PATH a prerequisite of the plugin. So then user only has to indicate that the project is a Stack project.

rikvdkleij commented 4 years ago

What’s your opinion? For the last option I need some help with testing, especially on Windows.

rikvdkleij commented 4 years ago

Decided to remove the whole SDK solution. So prerequisite of the plugin will become that stack has to be on PATH.

Maybe in the future add Facets to support other tools like Cabal or make Nix support explicit.

rikvdkleij commented 4 years ago

Fixed in beta76.

sir4ur0n commented 4 years ago

Seems to work fine, thank you :bow:

rikvdkleij commented 4 years ago

@Sir4ur0n In beta78 I have reverted the change which removed the Haskell SDK. In the next version I will create a setting which indicates to use stack from PATH instead of SDK.