rikvdkleij / intellij-haskell

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

Stack still uses default paths even if overrides are specified #641

Open extesy opened 3 years ago

extesy commented 3 years ago

OS: Windows 10 Plugin version: 1.0.0-beta85 IntelliJ: IntelliJ IDEA 2021.1 EAP Stack: 2.5.1 GHC: 8.10.4

When importing a new nearly empty project (and using "update haskell tools") the plugin very quickly runs through building/installing tools in a status line (less than a second) but it does not actually do anything. There are no error messages in the event log.

Everything else works fine: syntax highlighting, run/repl configurations, etc. It's just the tools are missing and everything that depends on those tools, including documentation in help tooltips.

Is there any way to see a more detailed log of "update haskell tools" command?

rikvdkleij commented 3 years ago

Yes, you can enable the Haskell event log, see README.

extesy commented 3 years ago

Ok, I figured out what's going on. I don't have that much space on %APPDATA% drive, so I set up stack.exe with a wrapper stack.cmd file which simply does this:

D:\Dev\Haskell\stack.exe --stack-root D:\Dev\Haskell\.stack-root --local-bin-path D:\Dev\Haskell\.stack-bin %*

Correspondingly, I configured Haskell Project SDK to point to this cmd file. However, this plugin tries to append its own root parameters to it which causes syntax error:

11:06 PM    D:/Dev/Haskell/stack.cmd -j2 --stack-root D:\Dev\Haskell\.intellij-haskell\lts-16 --resolver lts-16 --local-bin-path D:\Dev\Haskell\.intellij-haskell\lts-16\bin install hlint
11:06 PM    Invalid option `--stack-root'

I've tried putting --stack-root D:\Dev\Haskell\.stack-root --local-bin-path D:\Dev\Haskell\.stack-bin into the plugin's options instead and pointing it to stack.exe directly, but that does not seem to work because stack begins to download a lot of stuff into %APPDATA% and not the path I've specified.

So I see two issues here:

  1. Duplicate --stack-root parameters.
  2. Not passing "extra stack options" to stack in some circumstances.

I don't think it's possible to handle first case from the plugin, but the second issue seems like a bug to me. If I have these two options in the plugin settings, nothing should be downloaded into my %APPDATA% folder by stack.

rikvdkleij commented 3 years ago

I've tried putting --stack-root D:\Dev\Haskell.stack-root --local-bin-path D:\Dev\Haskell.stack-bin into the plugin's options instead and pointing it to stack.exe directly, but that does not seem to work because stack begins to download a lot of stuff into %APPDATA% and not the path I've specified.

Yes, that is expected behavior. The extra stack options are not mentioned for building the Haskell tools but for your Haskell project itself. If you want to change the location of where the Haskell tools are being built you have to change the path in the Cache path Haskell settings.

extesy commented 3 years ago

I did that, but if I don't use stack.cmd wrapper then the stack still downloads all its stuff into %APPDATA%, no matter what options I configure for the plugin:

image

There is no way currently to tell stack to only use custom paths without using stack.cmd wrapper.

rikvdkleij commented 3 years ago

I can’t follow anymore but before I go in all kind of rabbit holes (changes which work one system and break things on other systems, I’ve been there before :-) )and unmaintainable plugin changes, it looks to me that the root cause of your issue is the value of %APPDATA% My opinion is to change that one. Via Windows tool or via IntelliJ. See https://www.jetbrains.com/help/idea/absolute-path-variables.html

But I’m not a Windows user...

extesy commented 3 years ago

You aren't supposed to change APPDATA on a system level, besides it's isn't even necessary. When I manually invoke stack.exe --stack-root D:\Dev\Haskell\.stack-root --local-bin-path D:\Dev\Haskell\.stack-bin it works perfectly and nothing gets downloaded into APPDATA, so it's not a stack or intellij problem. The only case when stack does use APPDATA is when one of these arguments is missing. So it is this plugin that under some circumstances does not pass these arguments to stack. One example of when this happens is when you import a fresh new project.

You don't need to debug any cross-system issues. Here is a simple repro case for you:

  1. Delete all existing stack/cabal cache folders wherever they are in your system.
  2. Manually call stack with custom paths, for example: stack --resolver lts-17.4 --stack-root ~\.my-stack-root --local-bin-path ~\.my-stack-bin install hoogle and confirm that stack only uses your custom paths and there's nothing in the default cache location.
  3. Delete these new paths.
  4. Do the same through intellij-haskell plugin and compare the differences.