IntersectMBO / cardano-cli

This repository contains sources for the command-line interface (CLI) tool for interacting with the Cardano blockchain.
Apache License 2.0
33 stars 13 forks source link

Fix HLS in nix development shell #791

Closed palas closed 1 week ago

palas commented 1 month ago

Changelog

- description: |
    Update GHC in Nix shell and update HLS
  type:
  - maintenance    # not directly related to the code

Context

We've had a good experience with HLS 2.8 so we update GHC and HLS to be able to use 2.8.

How to trust this PR

Probably best to just test that it works for you.

Checklist

smelc commented 4 weeks ago

I'm going to do the same for API :+1:

[edit] This is https://github.com/IntersectMBO/cardano-api/pull/561

palas commented 4 weeks ago

Alas it doesn't seem to work locally :slightly_frowning_face:

There are two issues:

  1. Every opened file shows an error regarding ghcide (which is even not in the PATH of the shell :shrug:)

  2. There's an error regarding setInitialDynFlags:

Error condition, please check your setup and/or the issue tracker:

setInitialDynFlags: No entry for "GCC extra via C opts" in "/nix/store/j4f4vdh414qmrfbk0cwh9wv7asxf3b2b-ghc-shell-for-cardano-cli-ghc-9.8.2-env/lib/ghc-9.8.2/lib/settings"

image

Weirdly, linking seems to work: I can jump from a symbol to its declaration; but I don't have types in hovers.

I had trouble the first time I opened it too, and then compiled manually and retried and it worked :/

@carbolymer, any ideas? Or do you want to do like in cardano-api?

Also, are you opening code from the dev shell and do you have HLS path empty in the config?

smelc commented 4 weeks ago

@palas> no haskell-language-server* in the PATH, and code opened from the terminal :+1:

→ git branch --show-current
fix-hls
→ git rev-parse HEAD
fdf235b15a4fe941537f5548fa05af2400a22f15
→ cabal clean
→ cabal build all
→ which has
hash                     haskell-language-server
→ which haskell-language-server 
/nix/store/kdf9gfiabznqsp854z3zkl9f8z2qk01j-haskell-language-server-exe-haskell-language-server-2.8.0.0/bin/haskell-language-server
→ cabal build all
→ code . &
# Still same state as my previous message :-(
carbolymer commented 4 weeks ago

@palas

I had trouble the first time I opened it too, and then compiled manually and retried and it worked :/

That's my usual workflow. 😄 Also, I'm still frequently killing HLS 2.8 and restarting it because it gets stuck sometimes (less frequently than 2.6 though).

Also, are you opening code from the dev shell and do you have HLS path empty in the config?

I'm not using dev shell, I have ghc and hls installed on my system. I don't have hls path set, I'm letting neovim do the discovery.

palas commented 4 weeks ago

@palas> no haskell-language-server* in the PATH, and code opened from the terminal 👍

That is really odd, it is exactly what I get and it works fine. What do you get if you run haskell-language-server from the terminal? Also, it says something like:

2024-06-21T14:04:36.012281Z | Info | cabal --builddir=/etc/hie-cache/dist-cardano-cli-db470645dfdd132ffcb370027918caf2 v2-repl --with-compiler /etc/hie-cache/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /etc/hie-cache/ghc-pkg-abf1a1581548e8f73701fa45a8218161 ...

@smelc, could you remove the first dir (in my case /etc/hie-cache/dist-cardano-cli-db470645dfdd132ffcb370027918caf2), and probably also the file (in my case /etc/hie-cache/ghc-pkg-abf1a1581548e8f73701fa45a8218161), and then rebuild with cabal and then try to run haskell-language-server from the terminal, see if you get the same errors?

palas commented 4 weeks ago

Still I need to rebase and get the CI to pass...

smelc commented 4 weeks ago

@palas> no change after deleting the directory and the file you mentioned :face_with_diagonal_mouth:

code still fails with the same two errors (This is unsupported, ghcide..) and the setInitialDynFlags one.

I attached the log from haskell-language-server (after your procedure) in the terminal. It seems to do stuff and then exits normally:

hls_log.txt

palas commented 4 weeks ago

@palas> no change after deleting the directory and the file you mentioned 🫤

code still fails with the same two errors (This is unsupported, ghcide..) and the setInitialDynFlags one.

I attached the log from haskell-language-server (after your procedure) in the terminal. It seems to do stuff and then exits normally:

hls_log.txt

@smelc, if haskell-language-server exits normally, then I am inclined to think the problem is with vscode. Which versions of vscode and haskell plugin are you using?

smelc commented 3 weeks ago

@smelc, if haskell-language-server exits normally, then I am inclined to think the problem is with vscode

Yep, sounds legit.

@palas> here are my version numbers:

→ code --version
1.90.1
611f9bfce64f25108829dd295f54a6894e87339d
x64

Haskell extension version 2.4.4. What do you have? So that I try the same.

palas commented 3 weeks ago

@smelc, if haskell-language-server exits normally, then I am inclined to think the problem is with vscode

Yep, sounds legit.

@palas> here are my version numbers:

→ code --version
1.90.1
611f9bfce64f25108829dd295f54a6894e87339d
x64

Haskell extension version 2.4.4. What do you have? So that I try the same.

I have 1.85.2 for code, so yours is more recent. But I have 2.5.2 for the Haskell extension, so that is probably the problem. I would just update the extension.

smelc commented 3 weeks ago

@palas> Updating the haskell extension got rid of the ghcide error, but I still have the GCC extra via C opts" in "/nix/store/n5hri6flyp9szadydsyw1wnciabn1ldg-ghc-shell-for-cardano-cli-ghc-9.8.2-env/lib/ghc-9.8.2/lib/settings" one :shrug:

Anyway I'm approving, let's not block this one on my setup being broken. I'll go with ghcid in an external terminal if need be.

smelc commented 3 weeks ago

@palas> can you give me the output of which gcc and gcc --version in your Nix shell?

smelc commented 3 weeks ago

Woohoo found the problem \o/

I had a reference to an old HLS version in .vscode/settings.json and so HLS version wasn't 2.8.0.0 within vscode and I had forgotten about it, because this file is .gitignored. It works now :muscle: