haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.72k stars 367 forks source link

graphical editor not detecting ghc/cabal/stack due to incomplete $PATH in the init config file #236

Closed dreamsmasher closed 10 months ago

dreamsmasher commented 4 years ago

I'm having some issues with getting the extension to work right - currently, my Cabal installation is from ghcup, and Stack is built from Cabal (GHC 8.8.3). When loading projects in VSCode, I keep getting the error Project requires Cabal but it isn't installed. Stack projects give me the same error but with Stack, and the installation link just takes me to the ghcup page.

I've tried downloading the binary from the releases page and manually adding it to my configuration, as well as building it from source. No luck whatsoever, and using ghcide with the haskell-language-server-wrapper doesn't work either.

System: Arch Linux, i5-7600k, 16GB RAM, GHC 8.8.3

hie.yaml:

cradle:
  cabal:
    - path: "src/Main.hs"
      component: "mmvm:exe:mmvm"

    - path: "src/LibBinary.hs"
      component: "mmvm:exe:mmvm"

    - path: "src/Parse.hs"
      component: "mmvm:exe:mmvm"

    - path: "test"
      component: "mmvm:test:test"

    - path: "src"
      component: "mmvm:test:test"

settings.json:


{
    "editor.fontSize": 16,
    "editor.fontLigatures": true,
    "editor.fontFamily": "Hasklig", 
    "editor.fontWeight": "normal",
    "debug.console.fontFamily": "Terminus (TTF)",
    // "editor.suggestSelection": "first",
    // "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "editor.cursorStyle": "block",
    "python.jediEnabled": false,
    "editor.suggestSelection": "first",
    "terminal.integrated.shell.linux": "/bin/zsh",
    "terminal.integrated.fontFamily": "Hack", 
    "terminal.integrated.fontSize": 14,
    "vscode-neovim.neovimPath": "/usr/bin/nvim",
    "vscode-neovim.neovimInitPath": "~/.config/nvim/init.vim",
    "terminal.integrated.fontWeight": "normal",
    "terminal.integrated.fontWeightBold": "bold",
    "python.pythonPath": "/bin/pypy3",
    "workbench.colorTheme": "Wal",
    "haskell.enable": true,
    "haskell.hlintOn": true,
    "C_Cpp.clang_format_path": "/usr/bin/clang",
    "telemetry.enableTelemetry": false,
    "telemetry.enableCrashReporter": false,
    "window.zoomLevel": 2,
    "haskell.logFile": "/home/normie/Documents/misc/hs-hls.log",
    "haskell.trace.server": "messages",
    "haskell.formattingProvider": "brittany"

}

Any help would be appreciated, I'm currently doing fine with ALE/neovim but I'd like to be able to use an IDE for larger projects. Thanks!

ghost commented 1 year ago

Putting this in settings.json as suggested by @hasufell worked for me:

"haskell.serverEnvironment": { "PATH": "${HOME}/.ghcup/bin:${PATH}" }

Thank you for adding this setting! I'm also on Arch Linux with Xfce and VSCodium, installed from the curl script.

michaelpj commented 10 months ago

Tentatively closing since it seems there's an appropriate setting for this in the extension now

hasufell commented 10 months ago

We could add some logic in HLS, so it searches for a ghcup binary via:

And then possibly ask the user if they want to augment their PATH via vscode settings.

michaelpj commented 10 months ago

I do think this is a client (extension) issue though. I think HLS itself should just expect to be launched with the correct PATH set.

hasufell commented 10 months ago

Yes