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

haskell-language-server: nuked references to GHC causes hlint plugin to fail #107098

Closed
jul1u5 opened this issue Dec 17, 2020 · 6 comments
Closed
Labels

Comments

@jul1u5
Copy link
Contributor

jul1u5 commented Dec 17, 2020

Describe the bug
The builder for haskell-language-server removes references to GHC in HLS binary. This causes plugins like hlint to fail: haskell/haskell-language-server#591.

To Reproduce
Steps to reproduce the behavior:

  1. nix-shell -p haskell-language-server (on unstable channel)
  2. Launch VS Code (or any other editor that can connect to HLS)
  3. Try applying any hlint quick fix ("Apply hint: ...") in the editor
  4. Observe error

Expected behavior
Applying hlint suggestion via HLS should not fail.

Additional context
This seems to only affect haskell-language-server (and not haskellPackages.haskell-language-server). Applying hlint suggestions with haskellPackages.haskell-language-server works.

Here is the actual root cause: alanz/ghc-exactprint#96.

Maybe it would be possible to fix this in nixpkgs while we wait for the fix upstream? I think the references to GHC are removed here https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/haskell/haskell-language-server/withWrapper.nix#L19. I am not actually sure why it's necessary to remove these references. Is it because of using haskell.lib.justStaticExecutables? Would something else break if references were not removed?

Notify maintainers
@maralorn

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute: [ haskell-language-server ]
# a list of nixos modules affected by the problem
module:
@jul1u5 jul1u5 added the 0.kind: bug Something is broken label Dec 17, 2020
@maralorn
Copy link
Member

maralorn commented Dec 17, 2020

Huh, interesting. The hlint plugin works for me despite of the nuked references. But not sure if I've tried the other package you mentioned.

The problem is, that haskell-language-server per default pulls in 4 hls packages and therefore would pull in 4 ghc dependencies.
That means installing pkgs.haskell-language-server would have a closure size of around 4 GBs ...

So nothing would break explicitely, but I expect people would be annoyed. Finding a fix for this issue would be great!

@peti
Copy link
Member

peti commented Dec 18, 2020

The manual describes in section https://haskell4nix.readthedocs.io/nixpkgs-users-guide.html#how-to-install-a-compiler-with-libraries how to set the environment variables NIX_GHC_LIBDIR et al. I assume that you have not set that environment variable for your shell environment? If that is so, could you please set the variable (and the others) and try again? I'm pretty sure that configuring the path to your ghc installation in the environment would fix the issues you're seeing.

@jul1u5
Copy link
Contributor Author

jul1u5 commented Dec 27, 2020

Sorry for the late reply. I have found that NIX_GHC_LIBDIR does indeed fix the issue. Here is an environment that works for me:

with import <nixpkgs> {};
mkShell {
  buildInputs = [
    ghc
    cabal-install
    haskell-language-server
  ];

  shellHook = ''
    export NIX_GHC="${ghc}/bin/ghc"
    export NIX_GHCPKG="${ghc}/bin/ghc-pkg"
    export NIX_GHC_DOCDIR="${ghc}/share/doc/ghc/html"
    export NIX_GHC_LIBDIR="${ghc}/lib/ghc-$($NIX_GHC --numeric-version)"
  '';
}

However, I am now quite confused why these environment variables are not needed to be set up for the language server under haskellPackages.

@peti
Copy link
Member

peti commented Jan 22, 2021

I'm wondering about the state of this issue. Can we close this? Or is there any particular action left that we have to do?

@maralorn
Copy link
Member

@peti The question here is this, and I think you are the most qualified to answer it, would not nuking those references fix the noticed issue under some circumstances or is the claimed relation in this issue just wrong?

@jul1u5
Copy link
Contributor Author

jul1u5 commented Jan 23, 2021

I think we can close this. The culprit was that I didn't know about the NIX_GHC... env variables.

Also, the upstream issue seems to be fixed: haskell/haskell-language-server#1225.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants