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

Instructions for Hello World #4496

Open
davidspies opened this issue Feb 13, 2025 · 5 comments
Open

Instructions for Hello World #4496

davidspies opened this issue Feb 13, 2025 · 5 comments
Labels
type: support User support tickets, questions, help with setup etc.

Comments

@davidspies
Copy link

There seem to be a ten different versions of everything and just picking the latest never works. There's no clarity or documentation anywhere on which pieces are needed in order to get a working "Hello World" project, using either stack or cabal. I'm reporting this as an HLS issue because just picking the latest of everything besides HLS does seem to work if I don't care about editor integration.

Your environment

Which OS do you use?

Ubuntu 24.04

Which version of GHC do you use and how did you install it?

I've been jumping between the various versions in ghcup tui trying them out one-by-one.
The latest one I see here is 9.12.1.
9.10.1 is the closest I've gotten to everything working.

How is your project built (alternative: link to the project)?
I tried both cabal init and stack new.

Which LSP client (editor/plugin) do you use?

VSCode with no settings modifications whatsoever

Which version of HLS do you use and how did you install it?

The latest one available from ghcup tui: 2.9.0.1

Have you configured HLS in any way (especially: a hie.yaml file)?

No

What's wrong?

It takes excessive trial and error to find a combination of versions for tooling (ghc, hls, stack or cabal) where vscode doesn't complain and when vscode does complain, it gives no hints whatsoever as to how to fix it. There are no instructions anywhere for creating a new project which just works on opening vscode. Here's what I get when I use the latest of everything:

Image

Even when I do manage to get the right combination of versions, I get this error when trying to autoformat:

Image

I tried switching to stack and browsing a bit and eventually figured out it wanted me to use ghc 9.8.4 so I switched to that version. But now when I open vscode I see this error:

Image

Any help figuring out the right version combination would be much appreciated

@davidspies davidspies added status: needs triage type: support User support tickets, questions, help with setup etc. labels Feb 13, 2025
@fendor
Copy link
Collaborator

fendor commented Feb 13, 2025

Hi, thank you for the bug report!

The HLS docs show which GHC version HLS is currently supporting: https://haskell-language-server.readthedocs.io/en/stable/support/ghc-version-support.html

Also, following the ghcup recommendation should also always work, so ghc-9.4.8 and latest HLS according to:

Image

See the recommended tags.

That should give you a working installation.

Regarding the second error, you seem to be running into this issue: haskell/cabal#10457
We are trying to sync that up, but essentially using the interactive cabal init (cabal init -i) mode should give you a good default project.

The last HLS release was some time ago, which is very unfortunate as we don't support the 9.12.1 GHC releases yet

@fendor
Copy link
Collaborator

fendor commented Feb 13, 2025

Looking at your examples in detail, it seems like you are actually trying to manage your HLS installations yourself in VSCode? This might be the reason why everything is crashing.

The preferred way is to let GHCup handle that for you. On your first extension startup, VSCode asks you what you want to do, whether you want to use PATH or GHCup, you might have missed this option, making VSCode default to PATH.
To remedy this situation, go to Settings > Haskell : ManageHLS and select GHCup.

@davidspies
Copy link
Author

davidspies commented Feb 19, 2025

@fendor Thanks, I tried changing that (to Manage HLS installations with GHCup) and now when I create a fresh stack project I see this:

Image

@davidspies
Copy link
Author

davidspies commented Feb 19, 2025

I tried setting all the "recommended" versions in ghcup tui instead of all the latest versions, in particular including ghc-9.4.8. Then I created a new stack project, went into my stack.yaml and changed the snapshot to ghc-9.4.8 to line up with that choice. Now autoformat or ctrl-mouseover don't seem to do anything except cause it to get stuck "processing":

Image

Are you actually not finding any of these issues reproduceable? I'm pretty sure I cleared out any relevant custom settings I had. I don't have any dependencies or custom changes to anything, I'm just using stack new.


ETA: Actually it works fine if I only open Lib.rs. I actually even managed to autoformat once. The "Processing" thing happens as soon as I then also open Main.rs and ctrl+mouseover someFunc

@fendor
Copy link
Collaborator

fendor commented Feb 19, 2025

Well, your initial issues were caused by improper setup, of course I have a hard time to reproduce :) However, we did find it!

Stack support does have a couple of issues in HLS, see https://github.com/haskell/haskell-language-server/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22build%20tool%3A%20stack%22 for an overview.

The issue you describe sounds familiar to me, it might be #366. To fix it, you have to run stack build in your terminal successfully before running the editor.

Currently, you often have an easier time using cabal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: support User support tickets, questions, help with setup etc.
Projects
None yet
Development

No branches or pull requests

2 participants