hoovercj/vscode-ghc-mod

Better support for stack ghc-mod

Closed this issue · 4 comments

I usually install a project specific (and therefore ghc version specific) ghc-mod via stack build ghc-mod.

Unfortunately, this will not be found by vscode-ghc-mod.

Steps to reproduce:

  1. Install stack
  2. build ghc-mod (stack build ghc-mod)
  3. Open hs file in vscode
  4. Hover over a definition

Expected: Rich tooltip offers type information.
Actual result: vscode complains it cannot find ghc-mod. (Error: Command failed: ghc-mod version)

The comparable Atom package apparently includes stack path | grep bin-path in the path and finds the ghc-mod version as expected.
Alternatively allowing stack exec ghc-mod as a value for "haskell.ghcMod.executablePath" should help as well. (Error: spawn stack exec ghc-mod ENOENT)

Workaround: Specify the local ghc-mod path as workspace setting. Keep in mind to change it when stack lts-snapshot gets changed.

Thanks for the detailed report.

To clarify: from the command line, stack exec ghc-mod [args] behaves the same as ghc-mod [args], but it uses the local stack-installed ghc-mod?

Atom

I had a very brief look into atoms haskell-ghc-mod coding. The way they are doing it can be approximated here:
https://github.com/atom-haskell/haskell-ghc-mod/blob/f67b2be41b410d6e17f35b614fd8b1f2e97d67e1/lib/util.coffee#L83
https://github.com/atom-haskell/haskell-ghc-mod/blob/f67b2be41b410d6e17f35b614fd8b1f2e97d67e1/lib/util.coffee#L136

The result from calling stack path --local-install-root --snapshot-install-root (plus ./bin) gets added to the path. That is the snapshot local and the project local bin folder.

`stack exec

stack exec [--] <command> adds those to the PATH as well.

I still think both options should be valid solutions to the problem. You might want to get input from the atom haskell folks on why they chose the stack path variant.

My fresh, basic install of VS Code in combination with stack ghc-mod and your plugin version 1.0.1 does not seem to work. When opening a .hs file, language mode 'Plain Text' is detected. Haskell does not show up as an option when changing the Language Mode. No syntax high-lighting or any other language-related features are visible.
What I tried so far:

  • Modified the user settings to use "haskell.ghcMod.logLevel": "log". No output was visible in the DevTools console.
  • Modified the user setting for "haskell.ghcMod.executablePath" in all kinds of ways, with no visible effect.
  • Started VS Code via stack exec code, no difference visible.

Versions:

  • code -v -> 1.8.1
  • ghc-mod --version -> ghc-mod version 5.6.0.0 compiled by GHC 8.0.1
  • platform: Windows 7, 32 bits

@loewenstein - I believe I have a fix for your simple repro steps.

  • Update extension to 1.2.0
  • Install stack
  • build ghc-mod (stack build ghc-mod)
  • Open hs file in vscode
  • Notice error prompt. Select "user settings" from the error message
  • Set haskell.ghcMod.executablePath to "stack"
  • Switch back to hs file
  • Hover over a definition
  • Success! (hopefully)