Haskell and VS Code issues

I’ve tried this once on Linux and once on Windows and both times, same error so I guess I’m doing something wrong. Thing is, there’s virtually nothing on it online, and what there is involves people saying it worked perfectly for them.

Essentially, my process is this - install ghcup using the command from the website, say yes to all the extra stuff it wants to download, install the extensions on VSCode, make a .hs file. Open it, and what I get is an error in the bottom right hand corner of the screen - “Project requires GHCup but it isn’t installed”.

Bonus points for hlint not working, despite adding /usr/bin to the path variable.

Anyone know what to do here?

Managed to solve it half an hour after forum posting, so thats nice.

For anyone reading this in the future, I needed to add the ghcup executable to the extension settings. It was ~/.ghcup/bin/ghcup on linux.

1 Like

That’s strange. It should be adding ~/.ghcup/bin/ to the PATH during the installation :thinking:

Do you use a custom shell or something like that?

https://github.com/haskell/vscode-haskell#stackcabalghc-can-not-be-found

Launching VSCode via GUI sometimes doesn’t source ~/.bashrc, etc… but only /etc/profile.

I don’t understand why, perhaps it is a security feature, but the easiest workaround is usually to launch VSC via the terminal.

However, hasufell opened Add ghcup to PATH automatically · Issue #962 · haskell/vscode-haskell · GitHub s.t. we can squash this source of frustration once and for all.

1 Like

My understanding is that ~/.bashrc is only read by an interactive session. Long ago I set my system up to put all my customization in ~/.profile because of this.

1 Like

…because VSCode isn’t bash, dash, ksh, csh, zsh, etc - VSCode isn’t a shell. Or should it source all possible shell-configurations?

Surely the more appropriate thing to do here would be to update VSCode’s own user-specific configuration with the path to whatever version of GHCup the user has available locally, rather than rummaging through .profile or .??*rc files.

Let me rephrase, I don’t know what config files it reads and which it doesn’t.

I do know that for some extensions I manage for $day_job, guaranteeing that a given exe is in the path is almost impossible, especially when you bring remote execution into the mix.

The workaround is to put code in the extension that checks if the required exe is in the path, and explicitly add it to the path if not.

…I’m assuming(!!!) that somewhere in there is a call to rustup for similar reasons. That being the case, can what that extension does to find the path to rustup be replicated in the one for Haskell?

1 Like
1 Like