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

Weird error: Failed to find the GHC version of this Cabal project #3215

Closed
mouse07410 opened this issue Sep 23, 2022 · 5 comments
Closed

Weird error: Failed to find the GHC version of this Cabal project #3215

mouse07410 opened this issue Sep 23, 2022 · 5 comments
Labels
status: needs info Not actionable, because there's missing information type: support User support tickets, questions, help with setup etc.

Comments

@mouse07410
Copy link

mouse07410 commented Sep 23, 2022

Your environment

  • Which OS do you use? macOS Monterey 12.5.1

  • Which version of GHC do you use and how did you install it? GHC-9.4.2, installed via ghcup

  • How is your project built (alternative: link to the project)? Via Cabal-3.8.1.0

  • Which LSP client (editor/plugin) do you use? VS Codium+vscode-haskell

  • Which version of HLS do you use and how did you install it? 1.8.0.0 via ghcup

  • Which LSP client (editor/plugin) do you use? VS Code + Haskell v2.2.1

  • Have you configured HLS in any way (especially: a hie.yaml file)? No hie.yaml
    In the $HOME/Library/Application Support/Code/User/settings.json:

   "haskell.hlint.executablePath": "/Users/ur20980/.cabal/bin/hlint",
    "haskell.hlint.logLevel": "info",
    "haskell.hlint.ignore": ["camelCase"],
    "haskell.trace.server": "messages",
    "haskell.updateBehavior": "prompt",
    "haskelly.exec.reuseTerminal": true,
    "haskell.plugin.ghcide-type-lenses.config.mode": "always",
    "haskell.plugin.alternateNumberFormat.globalOn": false,
    "haskell.ghcupExecutablePath": "/Users/ur20980/.ghcup/bin/ghcup",
    "[haskell]": {
        "editor.defaultFormatter": "sjurmillidahl.ormolu-vscode"
    },
    "haskell.manageHLS": "GHCup",
    "haskell.plugin.eval.config.exception": true,
    "haskell.serverEnvironment": { 
        "PATH":        "${HOME}/.ghcup/bin:${PATH}",
    },
    "haskell.serverExecutablePath": "${HOME}/.ghcup/bin/haskell-language-server-wrapper",

Steps to reproduce

Start VS Code and open project directory.

Expected behaviour

No errors.

Actual behaviour

VS Code error message popup:

Failed to find the GHC version of this Cabal project. Error when calling cabal exec -v0 -- ghc --print-libdir

Source: Haskell (Extension)

In the Terminal:

$ cabal exec -v0 -- ghc --print-libdir
/Users/ur20980/.ghcup/ghc/9.4.2/lib/ghc-9.4.2/lib
$ 

Debug information

Tried to check Troubleshooting page, did not get far with VS Code on Mac.

$ haskell-language-server-wrapper --probe-tools
haskell-language-server version: 1.8.0.0 (GHC: 9.4.2) (PATH: /Users/ur20980/.ghcup/hls/1.8.0.0/lib/haskell-language-server-1.8.0.0/bin/haskell-language-server-wrapper)
Tool versions found on the $PATH
cabal:          3.8.1.0
stack:          2.9.1
ghc:            9.4.2

Tool versions in your project
ghc:            Not found
$ ghc -V
The Glorious Glasgow Haskell Compilation System, version 9.4.2
$ 
@mouse07410 mouse07410 added status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Sep 23, 2022
@blamario
Copy link

I've just encountered the same issue, except with GHC 9.2.4 and in Emacs with eglot. The command reported as problematic works in shell:

$ cabal exec -v0 -- ghc --print-libdir
/home/mario/.ghcup/ghc/9.2.4/lib/ghc-9.2.4

@blamario
Copy link

$ haskell-language-server-wrapper --probe-tools
haskell-language-server version: 1.8.0.0 (GHC: 9.4.2) (PATH: /home/mario/.ghcup/hls/1.8.0.0/lib/haskell-language-server-1.8.0.0/bin/haskell-language-server-wrapper)
Tool versions found on the $PATH
cabal:          3.8.1.0
stack:          Not found
ghc:            9.2.4

Tool versions in your project
ghc:            Not found

@mouse07410
Copy link
Author

Yes.

In my case, the problem seems related to HLS failing to get the correct PATH from the IDE(in my case- VS Code) regardless of how I set haskell.serverEnvironment. In fact, setting it seemed to make the problem worse.

@fendor
Copy link
Collaborator

fendor commented Sep 28, 2022

Iirc, @mouse07410 you should remove "haskell.serverExecutablePath": "${HOME}/.ghcup/bin/haskell-language-server-wrapper" as it overrides the "manageHLS": "GHCup" setting, which is what you want.
Also, for this bug report, please provide the logs of vscode https://github.com/haskell/vscode-haskell#troubleshooting

@michaelpj michaelpj added type: support User support tickets, questions, help with setup etc. status: needs info Not actionable, because there's missing information and removed type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. status: needs triage labels Oct 5, 2022
@mouse07410
Copy link
Author

Closing - this issue must have something to do with my config, and until I nail it, there's no point getting this team involved. Will re-open if/when find useful details to report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs info Not actionable, because there's missing information type: support User support tickets, questions, help with setup etc.
Projects
None yet
Development

No branches or pull requests

4 participants