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

HLS can't find dylib file in ~/.stack/programs/etc... #2815

Closed
tillydray opened this issue Apr 1, 2022 · 7 comments
Closed

HLS can't find dylib file in ~/.stack/programs/etc... #2815

tillydray opened this issue Apr 1, 2022 · 7 comments
Labels
status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@tillydray
Copy link

tillydray commented Apr 1, 2022

Is this a stack problem? Should I post there instead?

The tldr is that the problem seems to be that HLS can't find
/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/base-4.14.3.0/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib, or any of the fallback files. I installed everything manually because HLS needs a dynamically linked binary to
work with Template Haskell. See https://haskell-language-server.readthedocs.io/en/latest/troubleshooting.html#static-binaries

Your environment

Which OS do you use:

  • macOS 12.3

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

  • emacs 28
  • nvim
  • vscode

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

I think the only relevant thing is we use Template Haskell

Steps to reproduce

  • rm -rf ~/.stack (previously listed below install HLS but I believe this should go first)
  • Install Stack via wget -qO- https://get.haskellstack.org/ | sh
  • GHC: Download 8.10.7 tar.bz2 file from https://www.haskell.org/ghc/download_ghc_8_10_7.html#macosx_x86_64, followed instructions in INSTALL, which is to run ./configure && make install
  • Installed latest cabal-install binary directly from https://www.haskell.org/cabal/download.html, and moved it to /usr/local/bin
  • HLS: Download the repo and do stack install haskell-language-server --stack-yaml=stack-8.10.7.yaml per [https://haskell-language-server.readthedocs.io/en/latest/troubleshooting.html#static-binaries](the docs). I needed dynamically linked HLS binary because we have Template Haskell in our codebase.
  • rm -rf ~/.stack if it exists
  • cd to a haskell codebase that makes use of template haskell
  • run stack build to generate ~/.stack
  • open the codebase with Emacs 28, vscode, or neovim
  • HLS crashes

Expected behaviour

HLS works

Actual behaviour

HLS crashes

Include debug information

Output from lsp-haskell::stderr Found "[redacted]/[redacted]/ins/ins-leads-generator-component/hie.yaml" for "[redacted]/[redacted]/ins/ins-leads-generator-component/a" Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.6.1.1, Git revision 3084651 (2660 commits) x86_64 ghc-8.10.7 Current directory: [redacted]/[redacted]/ins/ins-leads-generator-component Operating system: darwin Arguments: ["--lsp","-d","-l","/var/folders/_y/7c6jcbcj2xs3xrrk2rnd99b80000gs/T/hls.log"] Cradle directory: [redacted]/[redacted]/ins/ins-leads-generator-component Cradle type: Stack

Tool versions found on the $PATH
cabal: 3.6.2.0
stack: 2.7.5
ghc: 8.10.7

Consulting the cradle to get project GHC version...
Project GHC version: 8.10.7
haskell-language-server exe candidates: ["haskell-language-server-8.10.7","haskell-language-server"]
Launching haskell-language-server exe at:[redacted]/.local/bin/haskell-language-server
dyld[92263]: Library not loaded: @rpath/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib
Referenced from: [redacted]/.local/bin/haskell-language-server
Reason: tried: '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/base-4.14.3.0/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/containers-0.6.5.1/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/filepath-1.4.2.1/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/ghc-8.10.7/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/ghc-prim-0.6.1/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/integer-gmp-1.0.3.0/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/rts/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/text-1.2.4.1/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/snapshots/x86_64-osx/eeddf135f4088ed43ec17b8b78528016ab57208ffc93672f58556205c25f4c4b/8.10.7/lib/x86_64-osx-ghc-8.10.7/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/Projects/haskell-language-server/.stack-work/dist/x86_64-osx/Cabal-3.2.1.0/build/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/Projects/haskell-language-server/.stack-work/install/x86_64-osx/eeddf135f4088ed43ec17b8b78528016ab57208ffc93672f58556205c25f4c4b/8.10.7/lib/x86_64-osx-ghc-8.10.7/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/base-4.14.3.0/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/containers-0.6.5.1/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/filepath-1.4.2.1/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/ghc-8.10.7/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/ghc-prim-0.6.1/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/integer-gmp-1.0.3.0/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/rts/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/programs/x86_64-osx/ghc-8.10.7/lib/ghc-8.10.7/text-1.2.4.1/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/.stack/snapshots/x86_64-osx/eeddf135f4088ed43ec17b8b78528016ab57208ffc93672f58556205c25f4c4b/8.10.7/lib/x86_64-osx-ghc-8.10.7/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/Projects/haskell-language-server/.stack-work/dist/x86_64-osx/Cabal-3.2.1.0/build/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '[redacted]/Projects/haskell-language-server/.stack-work/install/x86_64-osx/eeddf135f4088ed43ec17b8b78528016ab57208ffc93672f58556205c25f4c4b/8.10.7/lib/x86_64-osx-ghc-8.10.7/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '/usr/local/lib/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file), '/usr/lib/libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib' (no such file)

Process lsp-haskell stderr finished

@tillydray tillydray added status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Apr 1, 2022
@tillydray tillydray changed the title libHSprettyprinter-1.7.1-8zx93U4AMQACycDDx2d9mj-ghc8.10.7.dylib (no such file) HLS can't find dylib file in ~/.stack/programs/etc... Apr 1, 2022
@fendor
Copy link
Collaborator

fendor commented Apr 3, 2022

Hello, thank you for your bug report!

I am wondering, why are you deleting ~/.stack? HLS depends on the compilation artefacts available in this directory.

I guess this issue is rather about relocatable, dynamically linked HLS executables.
Maybe the Makefile can be utilised for that? cc @hasufell

@hasufell
Copy link
Member

hasufell commented Apr 3, 2022

Yeah, it appears you just built a dynamically linked HLS and then deleted all the dynamic libraries it links against. So yeah.

@tillydray
Copy link
Author

I am wondering, why are you deleting ~/.stack?

About once a week I get an error (I forget its content and didn't note it ☹️) when running stack build that says something about "unknown symbol". After searching online for "haskell stack unknown symbol", I think the error is the same, or similar, to here and here in case it's relevant.

Anyway, when troubleshooting this error, the only thing that seems to work consistently is rm -rf ~/.stack. I should clarify in my steps to reproduce, that I actually did rm -rf ~/.stack before the other steps, not after installing HLS. At least I think that's the correct order 🤔

In case it's relevant, to troubleshoot the issue, before doing rm -rf ~/.stack I have done the following

  • stack clean
  • stack purge
  • other steps I can't remember and didn't note

@psilospore
Copy link

This is the error Jason was seeing I believe:

symbol not found in flat namespace '_inszmlibzm0zi2zi4zi0zm8yzzOoOZZ7zzTiEaJuHC2zzO5j_InsuranceziTypesziQuotesGeneratedziCoverage1_zdfIsElmDefinitionCoverage1_closure

I also occasionally receive that.

@tillydray
Copy link
Author

tillydray commented Apr 5, 2022

Got the error again, here it is

Preprocessing executable 'ins-leads-bindable-aggregator-exe' for ins-leads-bindable-aggregator-0.1.0.0..
Building executable 'ins-leads-bindable-aggregator-exe' for ins-leads-bindable-aggregator-0.1.0.0..
Linking .stack-work/dist/x86_64-osx/Cabal-3.2.1.0/build/ins-leads-bindable-aggregator-exe/ins-leads-bindable-aggregator-exe ...
Undefined symbols for architecture x86_64:
  "_inszmleadszmbindablezmaggregatorzm0zi1zi0zi0zmKQMd3whtWTO2dn6kZZMOYl6_BindableziSelectQuoteziResponse_zdfFromJSONSelectQuoteResponse_closure", referenced from:
      _Lc2Q6b_info in libHSins-leads-bindable-aggregator-0.1.0.0-KQMd3whtWTO2dn6kZMOYl6.a(SelectedQuote.o)
      _Lu2Q8J_srt in libHSins-leads-bindable-aggregator-0.1.0.0-KQMd3whtWTO2dn6kZMOYl6.a(SelectedQuote.o)
  "_inszmleadszmbindablezmaggregatorzm0zi1zi0zi0zmKQMd3whtWTO2dn6kZZMOYl6_BindableziSelectQuoteziRequest_zdfToJSONSelectQuoteRequest_closure", referenced from:
      _Lc2Q6b_info in libHSins-leads-bindable-aggregator-0.1.0.0-KQMd3whtWTO2dn6kZMOYl6.a(SelectedQuote.o)
      _Lu2Q8J_srt in libHSins-leads-bindable-aggregator-0.1.0.0-KQMd3whtWTO2dn6kZMOYl6.a(SelectedQuote.o)
  "_inszmleadszmbindablezmaggregatorzm0zi1zi0zi0zmKQMd3whtWTO2dn6kZZMOYl6_BindableziSelectQuoteziRequest_zdWSelectQuoteRequest_info", referenced from:
      _Ls2P6L_info in libHSins-leads-bindable-aggregator-0.1.0.0-KQMd3whtWTO2dn6kZMOYl6.a(SelectedQuote.o)
      _Ls2P6U_info in libHSins-leads-bindable-aggregator-0.1.0.0-KQMd3whtWTO2dn6kZMOYl6.a(SelectedQuote.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)

actually, this might be a new error 🤔

@codygman
Copy link

codygman commented May 28, 2022

Try a setup that installs hls with ghcup and configures stack to use the ghcup installed GHC such as the setup in this repro:

https://github.com/codygman/EvalTest/tree/minimal-repro

Also, maybe related to #2857 and all of these types of issues might be helped by #2903.

@tillydray
Copy link
Author

Try a setup that installs hls with ghcup and configures stack to use the ghcup installed GHC

I had tried that and was still getting this problem, though at this point I don't recall how :(

Anyway, I'm closing this since the latest hls solves this I believe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

5 participants