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

VSC Extension can't find GHC when installed with GHCup #2331

Closed
SMC242 opened this issue Nov 6, 2021 · 7 comments
Closed

VSC Extension can't find GHC when installed with GHCup #2331

SMC242 opened this issue Nov 6, 2021 · 7 comments
Labels
type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@SMC242
Copy link

SMC242 commented Nov 6, 2021

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

bash: haskell-language-server-wrapper: command not found

Which OS do you use:
Manjaro
Which lsp-client do you use:
Code OSS
Describe your project (alternative: link to the project):
It's a standalone file
Contents of hie.yaml:
I don't have one

Steps to reproduce

  1. Install "Haskell Language Server" on Code OSS
  2. Install GHCup
  3. Run ghcup set ghc 8.10.7
  4. Load a .hs file in Code OSS

Expected behaviour

The extension should run

Actual behaviour

I get a toast saying "Project requires GHC but it isn't installed". ghc --version runs fine in a terminal and .ghcup/bin/ is in my PATH so I don't know what to do

This error didn't occur previously when I had installed GHC 9.0.1-4 via pacman. I wanted to switch to version 8.10.7 for better support

Include debug information

Execute in the root of your project the command haskell-language-server --debug . and paste the logs here:

Debug output:
bash: haskell-language-server: command not found

Paste the logs from the lsp-client, e.g. for VS Code

LSP logs:
[client][ERROR] Error executing '/home/eilidh/.config/Code - OSS/User/globalStorage/haskell.haskell/haskell-language-server-wrapper-1.4.0-linux --project-ghc-version' with error code 1
[client][ERROR] stderr: No 'hie.yaml' found. Try to discover the project type!
Cradle requires ghc but couldn't find it
Cradle {cradleRootDir = "/home/eilidh/Desktop/coding/playgrounds/haskell", cradleOptsProg = CradleAction: Default}
@jneira
Copy link
Member

jneira commented Nov 6, 2021

Hi, i think the cause might be the env loaded in gui apps dont use the same setup file than the cli (.bashrc). The file actually used could be /etc/profile and source .bashrc usually fix the issue.
See #236 for more info including some other workarounds than modify etc/profile:

  • open vscode within the shell konwn to have the correct path
  • open vscode with --force-user-env option

@SMC242
Copy link
Author

SMC242 commented Nov 6, 2021

I have added it to my /etc/profile like so:
PATH=$PATH:$HOME/eilidh/.ghcup/bin :/

I will try the other solutions later

@jneira
Copy link
Member

jneira commented Nov 6, 2021

have you restarted your windows session?

this environment is static, so simply modifying the .profile file is usually not enough, it also requires a logout/login from the X session (this is also valid for your terminal unless it is configured to use login shells)

see #236 (comment)

@SMC242
Copy link
Author

SMC242 commented Nov 6, 2021

Yes. When I restart, .ghcup/bin is still in my PATH but the extension fails to load

@SMC242
Copy link
Author

SMC242 commented Nov 6, 2021

The hie.yaml workaround fixed it for me. This is not a good fix as I want to just open a .hs file and have the extension work. It doesn't make sense to have to make a config file for little scripts

As others have said, it makes sense to have a GHCup directory setting

@jneira
Copy link
Member

jneira commented Nov 6, 2021

hmm, but hls for scripts uses directly ghc and you have ghc installed and available in PATH. I wonder if you have stack installed using another method and it is available for vscode but ghc and cabal are not.

@jneira jneira added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. type: setup labels Nov 6, 2021
@jneira
Copy link
Member

jneira commented Nov 6, 2021

As others have said, it makes sense to have a GHCup directory setting

Yeah, we have plans to add such option and use it for install/set the appropiate tools for the project at hand: haskell/vscode-haskell#483

Anyways i think we can close this one, as it is essentially the problem described in #236. Feel free to comment there any thought or suggestion. Thanks for reporting the issue!

@jneira jneira closed this as completed Nov 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

2 participants