Haskell-language-server: hlint seeking unavailable file /opt/ghc/8.8.4/lib/ghc-8.8.4/settings

Created on 12 Nov 2020  路  14Comments  路  Source: haskell/haskell-language-server

Subject of the issue

hlint seeking unavailabe file /opt/ghc/8.8.4/lib/ghc-8.8.4/settings
and refactor fail since this error

Your environment

Fedora 33, VSCode 1.51

  • Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools

    • 0.6

  • Which lsp-client do you use

    • vscode

  • Describe your project (alternative: link to the project)

    • single hs, no cradle, no cabal

  • Contents of hie.yaml

    • N/A

Steps to reproduce

  1. ghcup install ghc under ~/.ghcup
  2. open single hs file
  3. apply any hint from hlint
  4. prompt of the progress non stop run
  5. debug message said /opt/ghc/8.8.4/lib/ghc-8.8.4/settings file not available,
  6. symbolic link ~/.ghcup/ghc to /opt/ghc problem fix

Expected behaviour

seeking a correct ghc installed

Actual behaviour

seeking /opt/ghc/8.8.4/lib/ghc-8.8.4/settings

Include debug information

N/A

can-workaround hlint plugin linux bug

All 14 comments

Thanks for the bug report, it seems the root cause will be the same as #412, so apply-refact might be using ghc-paths (via ghc-exactprint), that store ghc libdir at compile time, making the executable non portable.
Building from source should fix it too.

On MacOS, in vscode, I get:

/Users/runner/.ghcup/ghc/8.6.5/lib/ghc-8.6.5/settings: openFile: does not exist (No such file or directory)

it looks like some artifact of build process... as vscode plugin uses prebuild binaries.

I suspect I'm hitting the same issue ("prompt of the progress non stop run" when applying hlint hints), but I can't find the same error in the HLS logs. After setting a log file and enabling tracing in the vscode extension settings, this is what I get:

2020-11-13 10:22:21.460582604 [ThreadId 367] - finish: applyHint (took 0.00s)
2020-11-13 10:22:21.460604569 [ThreadId 366] - applyHint:apply=[("/tmp/foo/src/Main.hs:7:1-14: Warning: Eta reduce\nFound:\n  foo x = (+ 1) x\nPerhaps:\n  foo = (+ 1)\n",[Replace {rtype = Decl, pos = SrcSpan {startLine = 7, startCol = 1, endLine = 7, endCol = 15}, subts = [("body",SrcSpan {startLine = 7, startCol = 9, endLine = 7, endCol = 13})], orig = "foo = body"}])]
2020-11-13 10:22:21.48032328 [ThreadId 369] - finish: hlint (took 0.00s)
2020-11-13 10:22:21.488593375 [ThreadId 7] - <--2--{"error":{"code":-32603,"message":"ExitFailure 1"},"jsonrpc":"2.0","id":8}
2020-11-13 10:22:21.495215152 [ThreadId 5] - ---> {"jsonrpc":"2.0","id":9,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///tmp/foo/src/Main.hs"},"range":{"start":{"line":6,"character":13},"end":{"line":6,"character":13}},"context":{"diagnostics":[{"range":{"start":{"line":6,"character":0},"end":{"line":6,"character":14}},"message":"/tmp/foo/src/Main.hs:7:1-14: Warning: Eta reduce\nFound:\n  foo x = (+ 1) x\nPerhaps:\n  foo = (+ 1)\n","severity":3,"code":"refact:Eta reduce","source":"hlint"}]}}}

I'm using v1.2.0 of the extension, with hls 0.6 downloaded by the extension. The project is a minimalist stack project for lts-16.21 (ghc 8.8.4).

Should I open a new issue or maybe enable more logging somewhere to confirm this is the same bug?

@ttylec yeah the hls executable is statically linked and it supposes that if some lib assumes the path to ghc is the compile time one, its calls will fail, making the executable partially non portable

@polux the error is present for other users, the unique option for enable logging is -d (you can see what options are enabled in the log, when the server is started)
you can try to apply the workaround, symlinking /Users/runner/.ghcup/ghc/${ghcVersion}/lib/ghc-${ghcVersion} to /path/to/your/ghc-${version}
(or compiling the server from source)

@jneira is there a way to pass an option to HLS from the vscode settings? I'd like to check that I'm hitting the same bug and not another one.

@polux yeah, you can enable logging in the extension settings:

imagen

@jneira sorry if I'm being slow, I don't know much about vscode. I had already enabled that option, which was the reason (I think) I was seeing the <--2-- and ---> in the logs. But apart from seeing these additional messages in the log, I haven't noticed any new output of any kind in vscode itself, let alone any message about /opt/ghc/8.8.4/lib/ghc-8.8.4/settings being not available. Where should I be able to observe this message after activating the option?

@polux dont worry, you can check the log in: Menu View -> Show output -> Choose Haskell(your_project) in the combo

Remove the log file setting to see all possible output in that pane.

If you dont see /opt/ghc/8.8.4/lib/ghc-8.8.4/settings file not available , it likely would be anothe issue.

I do see /opt/ghc/8.8.4/lib/ghc-8.8.4/settings: openFile: does not exist (No such file or directory) now. Thanks!

I have a similar issue on NixOS:

Missing file: /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-ghc-8.10.2/lib/ghc-8.10.2/settings

I can't really create a symlink in this directory, are there any other workarounds?

@jul1u5 i am afraid the unique workaround would be building hls from source, if you dont move the ghc used to build it afterwards, it should work.

I found that by using Nix package with attribute haskellPackages.haskell-language-server (instead of haskell-language-server) hlint suggestions actually work!

@jul1u5 were you using haskell.nix and a nix shell? I'm trying to work out how to fix this, can I add haskell-language-server to my shell.nix and get vscode to use that?

Was this page helpful?
0 / 5 - 0 ratings