Skip to content

Visual Studio Code: can't get HLS running #3367

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

Closed
Archill-56 opened this issue Nov 26, 2022 · 11 comments
Closed

Visual Studio Code: can't get HLS running #3367

Archill-56 opened this issue Nov 26, 2022 · 11 comments

Comments

@Archill-56
Copy link

DISTRIBUTION:
NAME="Linux Mint"
VERSION="20.1 (Ulyssa)"
ID=linuxmint
ID_LIKE=ubuntu
PRETTY_NAME="Linux Mint 20.1"
VERSION_ID="20.1"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=ulyssa
UBUNTU_CODENAME=focal

GHCUP INSTALLATION:
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
When installing, I appended the PATH-variable, said yes to HSL and to integration of stack with GHCup.

VSCODE INSTALLATION:
sudo apt install code

VSCODE HASKELL EXTENSION INSTALLATION v2.2.1
Via extensions in vscode (no other extension intalled)

SETTING UP THE STACK PROJECT
stack new --resolver=lts-19.33 HaskellTesti
stack setup
stack build

After setting up the stack project I opened the HaskellTesti folder in vscode and opened src/Lib.hs to the editor. The following happened:
2022-11-26 21:52:41.9970000 [client] INFO Finding haskell-language-server
2022-11-26 21:52:44.2550000 [client] INFO Checking for ghcup installation
2022-11-26 21:52:44.2630000 [client] INFO found ghcup at ghcup
2022-11-26 21:52:44.2680000 [client] INFO Executing 'ghcup --no-verbose upgrade' in cwd '/home/archill-56'
2022-11-26 21:52:45.1810000 [client] INFO Checking for ghcup installation
2022-11-26 21:52:45.2220000 [client] INFO found ghcup at ghcup
2022-11-26 21:52:45.2240000 [client] INFO Executing 'ghcup --no-verbose list -t hls -c installed -r' in cwd '/home/archill-56'
2022-11-26 21:52:45.4440000 [client] INFO Checking for ghcup installation
2022-11-26 21:52:45.4690000 [client] INFO found ghcup at ghcup
2022-11-26 21:52:45.4700000 [client] INFO Executing 'ghcup --no-verbose list -t cabal -c installed -r' in cwd '/home/archill-56'
2022-11-26 21:52:45.6890000 [client] INFO Checking for ghcup installation
2022-11-26 21:52:45.7090000 [client] INFO found ghcup at ghcup
2022-11-26 21:52:45.7110000 [client] INFO Executing 'ghcup --no-verbose list -t stack -c installed -r' in cwd '/home/archill-56'
2022-11-26 21:52:45.8740000 [client] INFO Checking for ghcup installation
2022-11-26 21:52:45.8860000 [client] INFO found ghcup at ghcup
2022-11-26 21:52:45.8870000 [client] INFO Executing 'ghcup --no-verbose whereis hls 1.8.0.0' in cwd '/home/archill-56'
2022-11-26 21:52:45.9070000 [client] INFO Checking for ghcup installation
2022-11-26 21:52:45.9190000 [client] INFO found ghcup at ghcup
2022-11-26 21:52:45.9210000 [client] INFO Executing 'ghcup --no-verbose whereis cabal 3.6.2.0' in cwd '/home/archill-56'
2022-11-26 21:52:45.9420000 [client] INFO Checking for ghcup installation
2022-11-26 21:52:45.9540000 [client] INFO found ghcup at ghcup
2022-11-26 21:52:45.9550000 [client] INFO Executing 'ghcup --no-verbose whereis stack 2.9.1' in cwd '/home/archill-56'
2022-11-26 21:52:45.9830000 [client] INFO Executing 'ghc --numeric-version' in cwd '/home/archill-56'
2022-11-26 21:52:46.0530000 [client] INFO Checking for ghcup installation
2022-11-26 21:52:46.0680000 [client] INFO found ghcup at ghcup
2022-11-26 21:52:46.0690000 [client] INFO Executing 'ghcup --no-verbose run --hls 1.8.0.0 --cabal 3.6.2.0 --stack 2.9.1 --install' in cwd '/home/archill-56'
2022-11-26 21:52:46.2460000 [client] INFO Working out the project GHC version. This might take a while...
2022-11-26 21:52:46.2480000 [client] INFO Executing 'haskell-language-server-wrapper --project-ghc-version' in cwd '/home/archill-56/Documents/Koodausprojektit/Haskell-projektit/HaskellTesti'
2022-11-26 21:52:46.2750000 [client] ERROR Error executing 'haskell-language-server-wrapper --project-ghc-version' with error code 1
2022-11-26 21:52:46.2750000 [client] ERROR stderr: haskell-language-server-wrapper: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by haskell-language-server-wrapper)

2022-11-26 21:52:46.2770000 [client] ERROR Error: haskell-language-server --project-ghc-version exited with exit code 1:

haskell-language-server-wrapper: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by haskell-language-server-wrapper)

2022-11-26 21:52:46.2790000 [client] INFO Executing 'ghc --numeric-version' in cwd '/home/archill-56'
2022-11-26 21:52:46.8410000 [client] INFO Platform constants: Linux_UnknownLinux, A_64
2022-11-26 21:52:46.8420000 [client] INFO Checking for ghcup installation
2022-11-26 21:52:46.8540000 [client] INFO found ghcup at ghcup
2022-11-26 21:52:46.8560000 [client] INFO Executing 'ghcup --no-verbose list -t hls -c installed -r' in cwd '/home/archill-56'
2022-11-26 21:52:47.0040000 [client] INFO Checking for ghcup installation
2022-11-26 21:52:47.0160000 [client] INFO found ghcup at ghcup
2022-11-26 21:52:47.0170000 [client] INFO Executing 'ghcup --no-verbose whereis bindir' in cwd '/home/archill-56'
2022-11-26 21:52:47.0570000 [client] INFO Checking for ghcup installation
2022-11-26 21:52:47.0740000 [client] INFO found ghcup at ghcup
2022-11-26 21:52:47.0770000 [client] INFO Executing 'ghcup --no-verbose whereis hls 1.8.0.0' in cwd '/home/archill-56'
2022-11-26 21:52:47.1090000 [client] INFO Checking for ghcup installation
2022-11-26 21:52:47.1240000 [client] INFO found ghcup at ghcup
2022-11-26 21:52:47.1250000 [client] INFO Executing 'ghcup --no-verbose whereis ghc 9.0.2' in cwd '/home/archill-56'
2022-11-26 21:52:47.1450000 [client] INFO Checking for ghcup installation
2022-11-26 21:52:47.1580000 [client] INFO found ghcup at ghcup
2022-11-26 21:52:47.1590000 [client] INFO Executing 'ghcup --no-verbose run --hls 1.8.0.0 --cabal 3.6.2.0 --stack 2.9.1 --ghc 9.0.2 --install' in cwd '/home/archill-56'
2022-11-26 21:52:47.3270000 [client] INFO Activating the language server in working dir: /home/archill-56/Documents/Koodausprojektit/Haskell-projektit/HaskellTesti (the workspace folder)
2022-11-26 21:52:47.3270000 [client] INFO run command: /home/archill-56/.ghcup/tmp/ghcup-ghc-9.0.2_cabal-3.6.2.0_hls-1.8.0.0_stack-2.9.1/haskell-language-server-wrapper --lsp -d
2022-11-26 21:52:47.3270000 [client] INFO debug command: /home/archill-56/.ghcup/tmp/ghcup-ghc-9.0.2_cabal-3.6.2.0_hls-1.8.0.0_stack-2.9.1/haskell-language-server-wrapper --lsp -d
2022-11-26 21:52:47.3270000 [client] INFO server environment variables:
2022-11-26 21:52:47.3270000 [client] INFO PATH=/home/archill-56/.ghcup/tmp/ghcup-ghc-9.0.2_cabal-3.6.2.0_hls-1.8.0.0_stack-2.9.1:/home/archill-56/.local/bin:/home/archill-56/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/archill-56/.cabal/bin:/home/archill-56/.ghcup/bin
2022-11-26 21:52:47.3370000 [client] INFO Starting language server
[Trace - 11:52:47 PM] Sending request 'initialize - (0)'.
[Error - 11:52:47 PM] Connection to server is erroring. Shutting down server.
[Trace - 11:52:47 PM] Sending request 'shutdown - (1)'.
/home/archill-56/.ghcup/tmp/ghcup-ghc-9.0.2_cabal-3.6.2.0_hls-1.8.0.0_stack-2.9.1/haskell-language-server-wrapper: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /home/archill-56/.ghcup/tmp/ghcup-ghc-9.0.2_cabal-3.6.2.0_hls-1.8.0.0_stack-2.9.1/haskell-language-server-wrapper)

So my problem is, that HLS is not clearly working for me at all. How can I fix this?

@fendor
Copy link
Collaborator

fendor commented Nov 26, 2022

Thank you for your bug report! This looks like bug in the pre-built binaries. I think you are pretty much forced to build HLS from source at the moment.

You may build hls from source via ghcup compile hls -g master --ghc 9.0.2.

cc @hasufell

@hasufell
Copy link
Member

Yes. The reason is that we build the wrapper for every GHC version, but only keep the one from the latest GHC, which is 9.2.4 in the bindist. 9.2.4 has the glibc "bug", because it bumped the Fedora version from 27 to 33.

What you can do is this:

  • nuke your ghcup installation
  • edit /etc/os-release and set your Mint version to 19
  • install ghcup again

Editing /etc/os-release is a huge hack and the next ghcup version will allow you to better overwrite the distro detection.

But this is also worth a shot.


For future reference:

Relevant lines in ghcup metadata: https://github.com/haskell/ghcup-metadata/blob/5b58beb3bdefe95c822ca29fa03f946eafbd6a46/ghcup-0.0.7.yaml#L3582

GHC bindists lacking fedora 27: https://gitlab.haskell.org/ghc/ghc/-/issues/22268

@hasufell
Copy link
Member

This is an instance of #3247

@Archill-56
Copy link
Author

Archill-56 commented Nov 27, 2022

Thank you for your bug report! This looks like bug in the pre-built binaries. I think you are pretty much forced to build HLS from source at the moment.

You may build hls from source via ghcup compile hls -g master --ghc 9.0.2.

cc @hasufell

I nuked the ghcup and reinstalled it wihout HLS, Then tried to do this, but the install did not work:

IN TERMINAL : ghcup compile hls -g master --ghc 9.0.2
[ Warn ] New ghc version available. To upgrade, run 'ghcup install ghc 9.4.3'
[ Warn ] New cabal version available. To upgrade, run 'ghcup install cabal 3.8.1.0'
[ Info ] Fetching git repo https://github.com/haskell/haskell-language-server.git at ref master (this may take a while)
[ Info ] Examining git ref master
[ ... ] HLS version (from cabal file): 1.8.0.0
[ ... ] commit hash: 9e5fc88
[ Info ] Building HLS 1.8.0.0 for GHC version 9.0.2
[ cabal ] gcc' failed in phase Linker'. (Exit code: 1)
[ cabal ] cabal: Failed to build ghc-source-gen-0.4.3.0 (which is req...
[ cabal ] exe:haskell-language-server-wrapper from haskell-language-s...
[ cabal ] exe:haskell-language-server from haskell-language-server-1....
[ cabal ] build log above for details.
[ cabal ]
[ Error ] BuildFailed failed in dir /home/archill-56/.ghcup/tmp/ghcup-a9813ec921ec489f: Process "cabal" with arguments ["v2-install",
[ ... ] "-w",
[ ... ] "ghc-9.0.2",
[ ... ] "--install-method=copy",
[ ... ] "--overwrite-policy=always",
[ ... ] "--disable-profiling",
[ ... ] "--disable-tests",
[ ... ] "--installdir=/home/archill-56/.ghcup/tmp/ghcup-a9813ec921ec489f/out/9.0.2",
[ ... ] "--project-file=cabal.project",
[ ... ] "exe:haskell-language-server",
[ ... ] "exe:haskell-language-server-wrapper"] failed with exit code 1.

@Archill-56
Copy link
Author

Yes. The reason is that we build the wrapper for every GHC version, but only keep the one from the latest GHC, which is 9.2.4 in the bindist. 9.2.4 has the glibc "bug", because it bumped the Fedora version from 27 to 33.

What you can do is this:

  • nuke your ghcup installation
  • edit /etc/os-release and set your Mint version to 19
  • install ghcup again

Editing /etc/os-release is a huge hack and the next ghcup version will allow you to better overwrite the distro detection.

But this is also worth a shot.

For future reference:

Relevant lines in ghcup metadata: https://github.com/haskell/ghcup-metadata/blob/5b58beb3bdefe95c822ca29fa03f946eafbd6a46/ghcup-0.0.7.yaml#L3582

GHC bindists lacking fedora 27: https://gitlab.haskell.org/ghc/ghc/-/issues/22268

I tried this also. First I nuked ghcup again. Then changed my /etc/os-release to:
NAME="Linux Mint"
VERSION="19.0 (Tara)"
ID=linuxmint
ID_LIKE=ubuntu
PRETTY_NAME="Linux Mint 19.0"
VERSION_ID="19.0"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=tara
UBUNTU_CODENAME=jammy

Then tried reinstall ghcup with HLS and stack integration:
Welcome to Haskell!

This script can download and install the following binaries:

  • ghcup - The Haskell toolchain installer
  • ghc - The Glasgow Haskell Compiler
  • cabal - The Cabal build tool for managing Haskell software
  • stack - A cross-platform program for developing Haskell projects (similar to cabal)
  • hls - (optional) A language server for developers to integrate with their editor/IDE

ghcup installs only into the following directory,
which can be removed anytime:
/home/archill-56/.ghcup

Press ENTER to proceed or ctrl-c to abort.
Note that this script can be re-run at any given time.


Detected bash shell on your system...
Do you want ghcup to automatically add the required PATH variable to "/home/archill-56/.bashrc"?

[P] Yes, prepend [A] Yes, append [N] No [?] Help (default is "P").

a

Do you want to install haskell-language-server (HLS)?
HLS is a language-server that provides IDE-like functionality
and can integrate with different editors, such as Vim, Emacs, VS Code, Atom, ...
Also see https://haskell-language-server.readthedocs.io/en/stable/

[Y] Yes [N] No [?] Help (default is "N").

y

Do you want to enable better integration of stack with GHCup?
This means that stack won't install its own GHC versions, but uses GHCup's.
For more information see:
https://docs.haskellstack.org/en/stable/yaml_configuration/#ghc-installation-customisation-experimental
If you want to keep stacks vanilla behavior, answer 'No'.

[Y] Yes [N] No [?] Help (default is "Y").

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 14.7M 100 14.7M 0 0 7090k 0 0:00:02 0:00:02 --:--:-- 7093k
[ Info ] downloading: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.7.yaml as file /home/archill-56/.ghcup/cache/ghcup-0.0.7.yaml
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 191k 100 191k 0 0 860k 0 --:--:-- --:--:-- --:--:-- 860k
[ Info ] Upgrading GHCup...
[ Warn ] No GHCup update available

System requirements
Note: You need the following packages: curl g++ gcc gmp make ncurses realpath xz-utils. Consult your distro documentation on the exact names of those packages.
Press ENTER to proceed or ctrl-c to abort.
Installation may take a while.

[ Info ] downloading: https://downloads.haskell.org/~ghc/9.2.5/ghc-9.2.5-x86_64-deb9-linux.tar.xz as file /home/archill-56/.ghcup/cache/ghc-9.2.5-x86_64-deb9-linux.tar.xz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 232M 100 232M 0 0 9092k 0 0:00:26 0:00:26 --:--:-- 10.5M
[ Info ] verifying digest of: ghc-9.2.5-x86_64-deb9-linux.tar.xz
[ Info ] Unpacking: ghc-9.2.5-x86_64-deb9-linux.tar.xz to /home/archill-56/.ghcup/tmp/ghcup-f311d333c589f3ae
[ Info ] Installing GHC (this may take a while)
[ ghc-make ] "utils/ghc-cabal/dist-install/build/tmp/ghc-cabal-bindis...
[ ghc-make ] Installing library in /home/archill-56/.ghcup/tmp/ghcup-...
[ ghc-make ] "/home/archill-56/.ghcup/tmp/ghcup-6576c59812c58694/home...
[ ghc-make ] /home/archill-56/.ghcup/tmp/ghcup-6576c59812c58694/home/...
[ ghc-make ] make[1]: *** [ghc.mk:989: install_packages] Error 127
[ ghc-make ] make: *** [Makefile:51: install] Error 2
[ Error ] Process "make" with arguments ["DESTDIR=/home/archill-56/.ghcup/tmp/ghcup-6576c59812c58694",
[ ... ] "install"] failed with exit code 2.
[ Error ] Also check the logs in /home/archill-56/.ghcup/logs
"_eghcup --cache install ghc recommended" failed!

The hack seems to not have worked out. I am thinking of changing my distro to suit Haskell development. Any suggestions on what distro is the best choice for that?

@hasufell
Copy link
Member

gcc' failed in phase Linker'. (Exit code: 1)

Looks like your toolchain is borked.

Try cabal repl -w ghc-9.0.2 --build-depends ghc-source-gen.

@Archill-56
Copy link
Author

cabal repl -w ghc-9.0.2 --build-depends ghc-source-gen

It opens up ghci:
Resolving dependencies...
Build profile: -w ghc-9.0.2 -O1
In order, the following will be built (use -v for more details):

  • fake-package-0 (lib) (first run)
    Configuring library for fake-package-0..
    Preprocessing library for fake-package-0..
    Warning: No exposed modules
    GHCi, version 9.0.2: https://www.haskell.org/ghc/ :? for help
    Loaded GHCi configuration from /tmp/cabal-repl.-161655/setcwd.ghci
    ghci>

@hasufell
Copy link
Member

Well, I don't know what exactly you're doing, but it doesn't build the specified package. Try to build the said package somehow.

@Archill-56
Copy link
Author

This time it worked out:

$ cabal repl -w ghc-9.0.2 --build-depends ghc-source-gen
Resolving dependencies...
Build profile: -w ghc-9.0.2 -O1
In order, the following will be built (use -v for more details):

  • ghc-source-gen-0.4.3.0 (lib) (requires build)
  • HaskellTesti-0.1.0.0 (lib) (first run)
    Starting ghc-source-gen-0.4.3.0 (lib)
    Building ghc-source-gen-0.4.3.0 (lib)
    Installing ghc-source-gen-0.4.3.0 (lib)
    Completed ghc-source-gen-0.4.3.0 (lib)
    Configuring library for HaskellTesti-0.1.0.0..
    Preprocessing library for HaskellTesti-0.1.0.0..
    GHCi, version 9.0.2: https://www.haskell.org/ghc/ :? for help
    [1 of 2] Compiling Lib ( src/Lib.hs, interpreted )
    [2 of 2] Compiling Paths_HaskellTesti ( /home/archill-56/Documents/Koodausprojektit/Haskell-projektit/HaskellTesti/dist-newstyle/build/x86_64-linux/ghc-9.0.2/HaskellTesti-0.1.0.0/build/autogen/Paths_HaskellTesti.hs, interpreted )
    Ok, two modules loaded.
    ghci>

Does this mean the toolchain is working somewhat?

@hasufell
Copy link
Member

I don't know. What did you change?

@Archill-56
Copy link
Author

I don't know. What did you change?

The first time, I was accidentally in the parent folder of the project. That is why it didn't build. Now, I have a different distro for Haskell development where everything works as intended. I hope you guys the best with solving this issue in the future. Thank you both for the help!

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

No branches or pull requests

3 participants