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

Fix HLS in nix development shell #791

Merged
merged 2 commits into from
Jul 9, 2024
Merged

Fix HLS in nix development shell #791

merged 2 commits into from
Jul 9, 2024

Conversation

palas
Copy link
Contributor

@palas palas commented Jun 18, 2024

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

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

@palas palas self-assigned this Jun 18, 2024
@palas palas requested review from a team as code owners June 18, 2024 21:35
@palas palas requested review from carbolymer, Jimbo4350 and disassembler and removed request for a team June 18, 2024 21:36
flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
@palas palas requested review from carbolymer and smelc June 20, 2024 01:50
@palas palas changed the title Add patched HLS version to nix development shell Fix HLS in nix development shell Jun 20, 2024
@smelc
Copy link
Contributor

smelc commented Jun 20, 2024

I'm going to do the same for API 👍

[edit] This is IntersectMBO/cardano-api#561

Copy link
Contributor

@smelc smelc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alas it doesn't seem to work locally 🙁

There are two issues:

  1. Every opened file shows an error regarding ghcide (which is even not in the PATH of the shell 🤷)
  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.

@palas
Copy link
Contributor Author

palas commented Jun 20, 2024

Alas it doesn't seem to work locally 🙁

There are two issues:

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

  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
Copy link
Contributor

smelc commented Jun 21, 2024

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

→ 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
Copy link
Contributor

@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
Copy link
Contributor Author

palas commented Jun 21, 2024

@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
Copy link
Contributor Author

palas commented Jun 21, 2024

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

@smelc
Copy link
Contributor

smelc commented Jun 21, 2024

@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

@palas
Copy link
Contributor Author

palas commented Jun 21, 2024

@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?

@palas palas force-pushed the fix-hls branch 2 times, most recently from 346cb8e to 1945e55 Compare June 21, 2024 18:48
@smelc
Copy link
Contributor

smelc commented Jun 24, 2024

@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
Copy link
Contributor Author

palas commented Jun 24, 2024

@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
Copy link
Contributor

smelc commented Jun 25, 2024

@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 🤷

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
Copy link
Contributor

smelc commented Jun 25, 2024

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

@smelc
Copy link
Contributor

smelc commented Jun 25, 2024

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 💪

flake.nix Outdated Show resolved Hide resolved
@palas palas enabled auto-merge July 9, 2024 16:49
@palas palas added this pull request to the merge queue Jul 9, 2024
@palas palas removed this pull request from the merge queue due to a manual request Jul 9, 2024
@palas palas added this pull request to the merge queue Jul 9, 2024
Merged via the queue into main with commit 09dc303 Jul 9, 2024
21 checks passed
@palas palas deleted the fix-hls branch July 9, 2024 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants