Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLS automatic version detection failing #1151

Closed
ethantruelove opened this issue Oct 24, 2024 · 9 comments
Closed

HLS automatic version detection failing #1151

ethantruelove opened this issue Oct 24, 2024 · 9 comments

Comments

@ethantruelove
Copy link

I'm still new to Stack/HLS/GHC, so my apologies if some of this is incorrect. I am attempting to have VSCode cleanly work with Stack out of the box. I installed ghcup binary per Haskell site and followed along to also install Stack. I have two projects, one that targets lts-22.11 (ghc-9.6.4) and one that targets lts-22.34 (ghc-9.6.6) in their stack.yaml files. I also found that 9.6.4 is supported by HLS 2.6.0.0 and 9.6.6 is supported by 2.9.0.1. Depending on which of those two HLS versions I have set as active on Stack, the extension will work for the corresponding project and fail for the other one due to not finding a proper HLS version. So in this configuration, the project with ghc-9.6.4 will not work with the VSCode extension:

ghcup tui information:
image

It looks like it successfully finds the HLS candidate but then doesn't end up selecting it. Separately, it does work when manually specifying the toolchain like in the README, i.e. adding this to each workspace's settings.json:

{
    "haskell.toolchain": {
        "hls": "2.6.0.0",
    },
    "haskell.manageHLS": "GHCup"
}

But I was under the impression that it should work automatically based on the Stack installs. Please let me know if there's anything I'm missing or other info that would be of help. Thanks!

Full debug when running in above config on ghc-9.6.4 on macOS Sequoia (Intel based):

2024-10-24 17:35:07.3890000 [client] DEBUG Environment variables:
2024-10-24 17:35:07.3900000 [client] DEBUG   PATH: /Users/ethan/.cabal/bin:/Users/ethan/.ghcup/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/TeX/texbin
2024-10-24 17:35:07.3900000 [client] INFO Finding haskell-language-server
2024-10-24 17:35:07.3910000 [client] INFO Searching for server executables haskell-language-server-wrapper,haskell-language-server in $PATH
2024-10-24 17:35:07.3910000 [client] INFO $PATH environment variable: /Users/ethan/.cabal/bin:/Users/ethan/.ghcup/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/TeX/texbin
2024-10-24 17:35:07.3970000 [client] INFO Found server executable in $PATH: haskell-language-server-wrapper
2024-10-24 17:35:07.3970000 [client] INFO Activating the language server in working dir: /Users/ethan/... (the workspace folder)
2024-10-24 17:35:07.3980000 [client] INFO run command: haskell-language-server-wrapper --lsp -d
2024-10-24 17:35:07.3980000 [client] INFO debug command: haskell-language-server-wrapper --lsp -d
2024-10-24 17:35:07.3980000 [client] INFO server cwd: /Users/ethan/...
2024-10-24 17:35:07.3980000 [client] INFO server environment variables:
2024-10-24 17:35:07.3980000 [client] DEBUG document selector patten: /Users/ethan/.../**/*
2024-10-24 17:35:07.4030000 [client] INFO Starting language server
[Trace - 12:35:07 PM] Sending request 'initialize - (0)'.
No 'hie.yaml' found. Try to discover the project type!
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 2.9.0.1 x86_64 ghc-9.10.1
Current directory: /Users/ethan/...
Operating system: darwin
Arguments: ["--lsp","-d"]
Cradle directory: /Users/ethan/...
Cradle type: Stack

Tool versions found on the $PATH
cabal:          3.10.3.0
stack:          3.1.1
ghc:            9.6.6


Consulting the cradle to get project GHC version...
2024-10-24T17:35:09.051917Z | Debug | stack --stack-yaml /Users/ethan/.../stack.yaml setup --silent
2024-10-24T17:35:09.516150Z | Debug | stack --stack-yaml /Users/ethan/.../stack.yaml exec ghc -- --numeric-version
Project GHC version: 9.6.4
haskell-language-server exe candidates: ["haskell-language-server-9.6.4","haskell-language-server"]
Failed to find a HLS version for GHC 9.6.4
Executable names we failed to find: haskell-language-server-9.6.4,haskell-language-server
 2024-10-24T17:35:09.519919Z | Info | Starting server
[Trace - 12:35:09 PM] Received request 'window/showMessageRequest - (0)'.
[Trace - 12:35:09 PM] Received response 'initialize - (0)' in 2101ms.
[Trace - 12:35:09 PM] Sending notification 'initialized'.
[Trace - 12:35:09 PM] Sending notification 'workspace/didChangeConfiguration'.
[Trace - 12:35:09 PM] Sending notification 'textDocument/didOpen'.
2024-10-24T17:35:09.529037Z | Error | LSP: no handler for: "initialized"
2024-10-24T17:35:09.529908Z | Debug[Trace - 12:35:09 PM] Received request 'client/registerCapability - (2)'.
[Trace - 12:35:09 PM] Sending notification 'workspace/didChangeConfiguration'.
[Trace - 12:35:09 PM] Sending response 'client/registerCapability - (2)'. Processing request took 1ms
 | LSP: set new config: {
  "checkProject": true,
  "formattingProvider": "ormolu",
  "ghcupExecutablePath": "",
  "indentationRules": { "enabled": true },
  "logFile": "",
  "manageHLS": "PATH",
  "maxCompletions": 40,
  "metadataURL": "",
  "openDocumentationInHackage": true,
  "openSourceInHackage": t[Trace - 12:35:09 PM] Received request 'workspace/configuration - (3)'.
[Trace - 12:35:09 PM] Sending response 'workspace/configuration - (3)'. Processing request took 0ms
rue,
  "plugin": {
    "alternateNumberFormat": { "globalOn": true },
    "cabal": {
      "codeActionsOn": true,
      "completionOn": true,
      "diagnosticsOn": true
    },
    "cabal-fmt": { "config": { "path": "cabal-fmt" } },
    "cabal-gild": { "config": { "path": "cabal-gild" } },
    "callHierarchy": { "globalOn": true },
    "changeTypeSignature": { "globalOn": true },
    "class": { "codeActionsOn": true, "codeLensOn": true },
    "eval": {
      "config": { "diff": true, "exception": false },
      "globalOn": true
    },
    "explicit-fields": { "globalOn": true },
    "explicit-fixity": { "globalOn": true },
    "fourmolu": { "config": { "external": false, "path": "fourmolu" } },
    "gadt": { "globalOn": true },
    "ghcide-code-actions-bindings": { "globalOn": true },
    "ghcide-code-actions-fill-holes": { "globalOn": true },
    "ghcide-code-actions-imports-exports": { "globalOn": true },
    "ghcide-code-actions-type-signatures": { "globalOn": true },
    "ghcide-completions": {
      "config": { "autoExtendOn": true, "snippetsOn": true },
      "globalOn": true
    },
    "ghcide-hover-and-symbols": { "hoverOn": true, "symbolsOn": true },
    "ghcide-type-lenses": { "config": { "mode": "always" }, "globalOn": true },
    "hlint": {
      "codeActionsOn": false,
      "config": { "flags": [  ] },
      "diagnosticsOn": false
    },
    "importLens": { "codeActionsOn": true, "codeLensOn": true },
    "moduleName": { "globalOn": true },
    "ormolu": { "config": { "external": false } },
    "overloaded-record-dot": { "globalOn": true },
    "pragmas-completion": { "globalOn": true },
    "pragmas-disable": { "globalOn": true },
    "pragmas-suggest": { "globalOn": true },
    "qualifyImportedNames": { "globalOn": true },
    "rename": { "config": { "crossModule": false }, "globalOn": true },
    "retrie": { "globalOn": true },
    "semanticTokens": {
      "config": {
        "classMethodToken": "method",
        "classToken": "class",
        "dataConstructorToken": "enumMember",
        "functionToken": "function",
        "moduleToken": "namespace",
        "operatorToken": "operator",
        "patternSynonymToken": "macro",
        "recordFieldToken": "property",
        "typeConstructorToken": "enum",
        "typeFamilyToken": "interface",
        "typeSynonymToken": "type",
        "typeVariableToken": "typeParameter",
        "variableToken": "variable"
      },
      "globalOn": false
    },
    "splice": { "globalOn": true },
    "stan": { "globalOn": false }
  },
  "promptBeforeDownloads": "true",
  "releasesDownloadStoragePath": "",
  "releasesURL": "",
  "serverEnvironment": {  },
  "serverExecutablePath": "",
  "serverExtraArgs": "",
  "sessionLoading": "singleComponent",
  "toolchain": { "hls": "2.6.0.0" },
  "trace": { "client": "debug", "server": "messages" },
  "upgradeGHCup": true
}
2024-10-24T17:35:09.544537Z [Trace - 12:35:09 PM] Received request 'workspace/configuration - (4)'.
[Trace - 12:35:09 PM] Sending response 'workspace/configuration - (4)'. Processing request took 0ms
| Error | LSP: no handler for: "workspace/didChangeConfiguration"
2024-10-24T17:35:09.545120Z | Debug | VFS: opening file:///Users/ethan/....hs file
2024-10-24T17:35:09.546180Z | Error | LSP: no handler for: "textDocument/didOpen"
2024-10-24T17:35:09.546667Z | Debug | LSP: set new config: {
  "checkProject": true,
  "formattingProvider": "ormolu",
  "ghcupExecutablePath": "",
  "indentationRules": { "enabled": true },
  "logFile": "",
  "manageHLS": "PATH",
  "maxCompletions": 40,
  "metadataURL": "",
  "openDocumentationInHackage": true,
  "openSourceInHackage": true,
  "plugin": {
    "alternateNumberFormat": { "globalOn": true },
    "cabal": {
      "codeActionsOn": true,
      "completionOn": true,
      "diagnosticsOn": true
    },
    "cabal-fmt": { "config": { "path": "cabal-fmt" } },
    "cabal-gild": { "config": { "path": "cabal-gild" } },
    "callHierarchy": { "globalOn": true },
    "changeTypeSignature": { "globalOn": true },
    "class": { "codeActionsOn": true, "codeLensOn": true },
    "eval": {
      "config": { "diff": true, "exception": false },
      "globalOn": true
    },
    "explicit-fields": { "globalOn": true },
    "explicit-fixity": { "globalOn": true },
    "fourmolu": { "config": { "external": false, "path": "fourmolu" } },
    "gadt": { "globalOn": true },
    "ghcide-code-actions-bindings": { "globalOn": true },
    "ghcide-code-actions-fill-holes": { "globalOn": true },
    "ghcide-code-actions-imports-exports": { "globalOn": true },
    "ghcide-code-actions-type-signatures": { "globalOn": true },
    "ghcide-completions": {
      "config": { "autoExtendOn": true, "snippetsOn": true },
      "globalOn": true
    },
    "ghcide-hover-and-symbols": { "hoverOn": true, "symbolsOn": true },
    "ghcide-type-lenses": { "config": { "mode": "always" }, "globalOn": true },
    "hlint": {
      "codeActionsOn": false,
      "config": { "flags": [  ] },
      "diagnosticsOn": false
    },
    "importLens": { "codeActionsOn": true, "codeLensOn": true },
    "moduleName": { "globalOn": true },
    "ormolu": { "config": { "external": false } },
    "overloaded-record-dot": { "globalOn": true },
    "pragmas-completion": { "globalOn": true },
    "pragmas-disable": { "globalOn": true },
    "pragmas-suggest": { "globalOn": true },
    "qualifyImportedNames": { "globalOn": true },
    "rename": { "config": { "crossModule": false }, "globalOn": true },
    "retrie": { "globalOn": true },
    "semanticTokens": {
      "config": {
        "classMethodToken": "method",
        "classToken": "class",
        "dataConstructorToken": "enumMember",
        "functionToken": "function",
        "moduleToken": "namespace",
        "operatorToken": "operator",
        "patternSynonymToken": "macro",
        "recordFieldToken": "property",
        "typeConstructorToken": "enum",
        "typeFamilyToken": "interface",
        "typeSynonymToken": "type",
        "typeVariableToken": "typeParameter",
        "variableToken": "variable"
      },
      "globalOn": false
    },
    "splice": { "globalOn": true },
    "stan": { "globalOn": false }
  },
  "promptBeforeDownloads": "true",
  "releasesDownloadStoragePath": "",
  "releasesURL": "",
  "serverEnvironment": {  },
  "serverExecutablePath": "",
  "serverExtraArgs": "",
  "sessionLoading": "singleComponent",
  "toolchain": { "hls": "2.6.0.0" },
  "trace": { "client": "debug", "server": "messages" },
  "upgradeGHCup": true
}
2024-10-24T17:35:09.561993Z | Error | LSP:[Trace - 12:35:09 PM] Received request 'workspace/configuration - (5)'.
[Trace - 12:35:09 PM] Sending response 'workspace/configuration - (5)'. Processing request took 0ms
 no handler for: "workspace/didChangeConfiguration"
2024-10-24T17:35:09.562598Z | Debug | LSP: set new config: {
  "checkProject": true,
  "formattingProvider": "ormolu",
  "ghcupExecutablePath": "",
  "indentationRules": { "enabled": true },
  "logFile": "",
  "manageHLS": "PATH",
  "maxCompletions": 40,
  "metadataURL": "",
  "openDocumentationInHackage": true,
  "openSourceInHackage": true,
  "plugin": {
    "alternateNumberFormat": { "globalOn": true },
    "cabal": {
      "codeActionsOn": true,
      "completionOn": true,
      "diagnosticsOn": true
    },
    "cabal-fmt": { "config": { "path": "cabal-fmt" } },
    "cabal-gild": { "config": { "path": "cabal-gild" } },
    "callHierarchy": { "globalOn": true },
    "changeTypeSignature": { "globalOn": true },
    "class": { "codeActionsOn": true, "codeLensOn": true },
    "eval": {
      "config": { "diff": true, "exception": false },
      "globalOn": true
    },
    "explicit-fields": { "globalOn": true },
    "explicit-fixity": { "globalOn": true },
    "fourmolu": { "config": { "external": false, "path": "fourmolu" } },
    "gadt": { "globalOn": true },
    "ghcide-code-actions-bindings": { "globalOn": true },
    "ghcide-code-actions-fill-holes": { "globalOn": true },
    "ghcide-code-actions-imports-exports": { "globalOn": true },
    "ghcide-code-actions-type-signatures": { "globalOn": true },
    "ghcide-completions": {
      "config": { "autoExtendOn": true, "snippetsOn": true },
      "globalOn": true
    },
    "ghcide-hover-and-symbols": { "hoverOn": true, "symbolsOn": true },
    "ghcide-type-lenses": { "config": { "mode": "always" }, "globalOn": true },
    "hlint": {
      "codeActionsOn": false,
      "config": { "flags": [  ] },
      "diagnosticsOn": false
    },
    "importLens": { "codeActionsOn": true, "codeLensOn": true },
    "moduleName": { "globalOn": true },
    "ormolu": { "config": { "external": false } },
    "overloaded-record-dot": { "globalOn": true },
    "pragmas-completion": { "globalOn": true },
    "pragmas-disable": { "globalOn": true },
    "pragmas-suggest": { "globalOn": true },
    "qualifyImportedNames": { "globalOn": true },
    "rename": { "config": { "crossModule": false }, "globalOn": true },
    "retrie": { "globalOn": true },
    "semanticTokens": {
      "config": {
        "classMethodToken": "method",
        "classToken": "class",
        "dataConstructorToken": "enumMember",
        "functionToken": "function",
        "moduleToken": "namespace",
        "operatorToken": "operator",
        "patternSynonymToken": "macro",
        "recordFieldToken": "property",
        "typeConstructorToken": "enum",
        "typeFamilyToken": "interface",
        "typeSynonymToken": "type",
        "typeVariableToken": "typeParameter",
        "variableToken": "variable"
      },
      "globalOn": false
    },
    "splice": { "globalOn": true },
    "stan": { "globalOn": false }
  },
  "promptBeforeDownloads": "true",
  "releasesDownloadStoragePath": "",
  "releasesURL": "",
  "serverEnvironment": {  },
  "serverExecutablePath": "",
  "serverExtraArgs": "",
  "sessionLoading": "singleComponent",
  "toolchain": { "hls": "2.6.0.0" },
  "trace": { "client": "debug", "server": "messages" },
  "upgradeGHCup": true
}
2024-10-24T17:35:09.578945Z | Debug | LSP: set new config: {
  "checkProject": true,
  "formattingProvider": "ormolu",
  "ghcupExecutablePath": "",
  "indentationRules": { "enabled": true },
  "logFile": "",
  "manageHLS": "PATH",
  "maxCompletions": 40,
  "metadataURL": "",
  "openDocumentationInHackage": true,
  "openSourceInHackage": true,
  "plugin": {
    "alternateNumberFormat": { "globalOn": true },
    "cabal": {
      "codeActionsOn": true,
      "completionOn": true,
      "diagnosticsOn": true
    },
    "cabal-fmt": { "config": { "path": "cabal-fmt" } },
    "cabal-gild": { "config": { "path": "cabal-gild" } },
    "callHierarchy": { "globalOn": true },
    "changeTypeSignature": { "globalOn": true },
    "class": { "codeActionsOn": true, "codeLensOn": true },
    "eval": {
      "config": { "diff": true, "exception": false },
      "globalOn": true
    },
    "explicit-fields": { "globalOn": true },
    "explicit-fixity": { "globalOn": true },
    "fourmolu": { "config": { "external": false, "path": "fourmolu" } },
    "gadt": { "globalOn": true },
    "ghcide-code-actions-bindings": { "globalOn": true },
    "ghcide-code-actions-fill-holes": { "globalOn": true },
    "ghcide-code-actions-imports-exports": { "globalOn": true },
    "ghcide-code-actions-type-signatures": { "globalOn": true },
    "ghcide-completions": {
      "config": { "autoExtendOn": true, "snippetsOn": true },
      "globalOn": true
    },
    "ghcide-hover-and-symbols": { "hoverOn": true, "symbolsOn": true },
    "ghcide-type-lenses": { "config": { "mode": "always" }, "globalOn": true },
    "hlint": {
      "codeActionsOn": false,
      "config": { "flags": [  ] },
      "diagnosticsOn": false
    },
    "importLens": { "codeActionsOn": true, "codeLensOn": true },
    "moduleName": { "globalOn": true },
    "ormolu": { "config": { "external": false } },
    "overloaded-record-dot": { "globalOn": true },
    "pragmas-completion": { "globalOn": true },
    "pragmas-disable": { "globalOn": true },
    "pragmas-suggest": { "globalOn": true },
    "qualifyImportedNames": { "globalOn": true },
    "rename": { "config": { "crossModule": false }, "globalOn": true },
    "retrie": { "globalOn": true },
    "semanticTokens": {
      "config": {
        "classMethodToken": "method",
        "classToken": "class",
        "dataConstructorToken": "enumMember",
        "functionToken": "function",
        "moduleToken": "namespace",
        "operatorToken": "operator",
        "patternSynonymToken": "macro",
        "recordFieldToken": "property",
        "typeConstructorToken": "enum",
        "typeFamilyToken": "interface",
        "typeSynonymToken": "type",
        "typeVariableToken": "typeParameter",
        "variableToken": "variable"
      },
      "globalOn": false
    },
    "splice": { "globalOn": true },
    "stan": { "globalOn": false }
  },
  "promptBeforeDownloads": "true",
  "releasesDownloadStoragePath": "",
  "releasesURL": "",
  "serverEnvironment": {  },
  "serverExecutablePath": "",
  "serverExtraArgs": "",
  "sessionLoading": "singleComponent",
  "toolchain": { "hls": "2.6.0.0" },
  "trace": { "client": "debug", "server": "messages" },
  "upgradeGHCup": true
}
2024-10-24T17:35:09.597259Z | Debug | LSP: set new config: {
  "checkProject": true,
  "formattingProvider": "ormolu",
  "ghcupExecutablePath": "",
  "indentationRules": { "enabled": true },
  "logFile": "",
  "manageHLS": "PATH",
  "maxCompletions": 40,
  "metadataURL": "",
  "openDocumentationInHackage": true,
  "openSourceInHackage": true,
  "plugin": {
    "alternateNumberFormat": { "globalOn": true },
    "cabal": {
      "codeActionsOn": true,
      "completionOn": true,
      "diagnosticsOn": true
    },
    "cabal-fmt": { "config": { "path": "cabal-fmt" } },
    "cabal-gild": { "config": { "path": "cabal-gild" } },
    "callHierarchy": { "globalOn": true },
    "changeTypeSignature": { "globalOn": true },
    "class": { "codeActionsOn": true, "codeLensOn": true },
    "eval": {
      "config": { "diff": true, "exception": false },
      "globalOn": true
    },
    "explicit-fields": { "globalOn": true },
    "explicit-fixity": { "globalOn": true },
    "fourmolu": { "config": { "external": false, "path": "fourmolu" } },
    "gadt": { "globalOn": true },
    "ghcide-code-actions-bindings": { "globalOn": true },
    "ghcide-code-actions-fill-holes": { "globalOn": true },
    "ghcide-code-actions-imports-exports": { "globalOn": true },
    "ghcide-code-actions-type-signatures": { "globalOn": true },
    "ghcide-completions": {
      "config": { "autoExtendOn": true, "snippetsOn": true },
      "globalOn": true
    },
    "ghcide-hover-and-symbols": { "hoverOn": true, "symbolsOn": true },
    "ghcide-type-lenses": { "config": { "mode": "always" }, "globalOn": true },
    "hlint": {
      "codeActionsOn": false,
      "config": { "flags": [  ] },
      "diagnosticsOn": false
    },
    "importLens": { "codeActionsOn": true, "codeLensOn": true },
    "moduleName": { "globalOn": true },
    "ormolu": { "config": { "external": false } },
    "overloaded-record-dot": { "globalOn": true },
    "pragmas-completion": { "globalOn": true },
    "pragmas-disable": { "globalOn": true },
    "pragmas-suggest": { "globalOn": true },
    "qualifyImportedNames": { "globalOn": true },
    "rename": { "config": { "crossModule": false }, "globalOn": true },
    "retrie": { "globalOn": true },
    "semanticTokens": {
      "config": {
        "classMethodToken": "method",
        "classToken": "class",
        "dataConstructorToken": "enumMember",
        "functionToken": "function",
        "moduleToken": "namespace",
        "operatorToken": "operator",
        "patternSynonymToken": "macro",
        "recordFieldToken": "property",
        "typeConstructorToken": "enum",
        "typeFamilyToken": "interface",
        "typeSynonymToken": "type",
        "typeVariableToken": "typeParameter",
        "variableToken": "variable"
      },
      "globalOn": false
    },
    "splice": { "globalOn": true },
    "stan": { "globalOn": false }
  },
  "promptBeforeDownloads": "true",
  "releasesDownloadStoragePath": "",
  "releasesURL": "",
  "serverEnvironment": {  },
  "serverExecutablePath": "",
  "serverExtraArgs": "",
  "sessionLoading": "singleComponent",
  "toolchain": { "hls": "2.6.0.0" },
  "trace": { "client": "debug", "server": "messages" },
  "upgradeGHCup": true
}
@fendor
Copy link
Collaborator

fendor commented Oct 24, 2024

Thanks for the bug report!

At a first glance, it looks like manageHLS is set to PATH in the settings. There is a pop-up the first time you launch vscode-haskell asking you whether you want to manage HLS using ghcup or by yourself by using PATH.

Can you try to go to Preferences > Settings > Extensions: Haskell > manageHLS in VSCode? Is GHCup selected in there or is it PATH?

@ethantruelove
Copy link
Author

Yes, it is set to PATH. If I change it to GHCup then I can manually specify the version also under the toolchain setting.

@fendor
Copy link
Collaborator

fendor commented Oct 24, 2024

Yes, but vscode-haskell will also launch the correct HLS and GHC version based on what you have in stack.yaml, so there is no need to manually specify the toolchain.

@ethantruelove
Copy link
Author

ethantruelove commented Oct 24, 2024

Right, but if I have it set to PATH and no manual specification of toolchain, then it fails to launch the proper HLS version it seems edit: when Stack has the improper HLS version selected

@fendor
Copy link
Collaborator

fendor commented Oct 24, 2024

If you select PATH, then it is up to you to make sure the $PATH is setup correctly s.t. haskell-language-server-wrapper and haskell-language-server-<ghcver> are found on $PATH. Unless you have a specific use-case, you likely should always use GHCup to manage your HLS installation.

when Stack has the improper HLS version selected

Could you elaborate on this? In stack.yaml, you only specify a GHC version to compile your project with. vscode-haskell should automatically launch the correct HLS version if set to GHCup. If it is set to PATH, you need to make sure the correct HLS version which supports your selected GHC version is on $PATH. See https://haskell-language-server.readthedocs.io/en/stable/support/ghc-version-support.html#current-ghc-version-support-status for the up-to-date documentation which HLS version supports which GHC version.

@ethantruelove
Copy link
Author

I think I may have indeed misunderstood something about how the versions are used. It seems to me that when set to PATH, the extension will use only the version targeted by haskell-language-server-wrapper is used. Is that correct?

when Stack has the improper HLS version selected

I used the wrong phrase here; I meant when running ghcup set hls <version> to select it as active. I see now that this is in charge of picking what version haskell-language-server-wrapper is pointed to.

I totally understand that by using the PATH option that it's up to me to have my Path configured appropriately, but I would have thought that as I have all the binaries on the path, that it would match the needed ghc version with the needed hls version found on the path, but perhaps it does not and relies entirely on the haskell-language-server-wrapper?

See my path and binaries:

ethan@Gagarin bin % echo $PATH
/Users/ethan/.cabal/bin:/Users/ethan/.ghcup/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/TeX/texbin
ethan@Gagarin bin % pwd
/Users/ethan/.ghcup/bin
ethan@Gagarin bin % ls -l | grep haskell-language
lrwxr-xr-x  1 ethan  staff        38 Oct 24 15:34 haskell-language-server-9.10.1 -> haskell-language-server-9.10.1~2.9.0.1
lrwxr-xr-x  1 ethan  staff        49 Oct 24 09:42 haskell-language-server-9.10.1~2.9.0.1 -> ../hls/2.9.0.1/bin/haskell-language-server-9.10.1
lrwxr-xr-x  1 ethan  staff        37 Oct 24 15:34 haskell-language-server-9.2.8 -> haskell-language-server-9.2.8~2.9.0.1
lrwxr-xr-x  1 ethan  staff        48 Oct 24 09:54 haskell-language-server-9.2.8~2.6.0.0 -> ../hls/2.6.0.0/bin/haskell-language-server-9.2.8
lrwxr-xr-x  1 ethan  staff        48 Oct 24 09:42 haskell-language-server-9.2.8~2.9.0.1 -> ../hls/2.9.0.1/bin/haskell-language-server-9.2.8
lrwxr-xr-x  1 ethan  staff        37 Oct 24 15:34 haskell-language-server-9.4.8 -> haskell-language-server-9.4.8~2.9.0.1
lrwxr-xr-x  1 ethan  staff        48 Oct 24 09:54 haskell-language-server-9.4.8~2.6.0.0 -> ../hls/2.6.0.0/bin/haskell-language-server-9.4.8
lrwxr-xr-x  1 ethan  staff        48 Oct 24 09:42 haskell-language-server-9.4.8~2.9.0.1 -> ../hls/2.9.0.1/bin/haskell-language-server-9.4.8
lrwxr-xr-x  1 ethan  staff        48 Oct 24 09:54 haskell-language-server-9.6.4~2.6.0.0 -> ../hls/2.6.0.0/bin/haskell-language-server-9.6.4
lrwxr-xr-x  1 ethan  staff        37 Oct 24 15:34 haskell-language-server-9.6.5 -> haskell-language-server-9.6.5~2.9.0.1
lrwxr-xr-x  1 ethan  staff        48 Oct 24 09:42 haskell-language-server-9.6.5~2.9.0.1 -> ../hls/2.9.0.1/bin/haskell-language-server-9.6.5
lrwxr-xr-x  1 ethan  staff        37 Oct 24 15:34 haskell-language-server-9.6.6 -> haskell-language-server-9.6.6~2.9.0.1
lrwxr-xr-x  1 ethan  staff        48 Oct 24 09:42 haskell-language-server-9.6.6~2.9.0.1 -> ../hls/2.9.0.1/bin/haskell-language-server-9.6.6
lrwxr-xr-x  1 ethan  staff        48 Oct 24 09:54 haskell-language-server-9.8.1~2.6.0.0 -> ../hls/2.6.0.0/bin/haskell-language-server-9.8.1
lrwxr-xr-x  1 ethan  staff        37 Oct 24 15:34 haskell-language-server-9.8.2 -> haskell-language-server-9.8.2~2.9.0.1
lrwxr-xr-x  1 ethan  staff        48 Oct 24 09:42 haskell-language-server-9.8.2~2.9.0.1 -> ../hls/2.9.0.1/bin/haskell-language-server-9.8.2
lrwxr-xr-x  1 ethan  staff        39 Oct 24 15:34 haskell-language-server-wrapper -> haskell-language-server-wrapper-2.9.0.1
lrwxr-xr-x  1 ethan  staff        86 Oct 24 09:54 haskell-language-server-wrapper-2.6.0.0 -> ../hls/2.6.0.0/lib/haskell-language-server-2.6.0.0/bin/haskell-language-server-wrapper
lrwxr-xr-x  1 ethan  staff        86 Oct 24 09:42 haskell-language-server-wrapper-2.9.0.1 -> ../hls/2.9.0.1/lib/haskell-language-server-2.9.0.1/bin/haskell-language-server-wrapper

@fendor
Copy link
Collaborator

fendor commented Oct 24, 2024

I totally understand that by using the PATH option that it's up to me to have my Path configured appropriately, but I would have thought that as I have all the binaries on the path, that it would match the needed ghc version with the needed hls version found on the path, but perhaps it does not and relies entirely on the haskell-language-server-wrapper?

Yes, it looks for haskell-language-server-wrapper and the wrapper only understands binaries of the form haskell-language-server-<ghc-ver> and haskell-language-server. The ~<hls-version> suffix is a ghcup convention and the wrapper isn't aware of that convention (even though, arguably we could support that).

@ethantruelove
Copy link
Author

Got it, thank you! I appreciate the help, and I suppose this is a non-issue

@fendor
Copy link
Collaborator

fendor commented Oct 25, 2024

Happy to help, feel free to open another issue when you encounter problems!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants