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

using lsp-metals under guix with coursier linux binary launcher #68

Open
muradm opened this issue Apr 15, 2022 · 1 comment
Open

using lsp-metals under guix with coursier linux binary launcher #68

muradm opened this issue Apr 15, 2022 · 1 comment

Comments

@muradm
Copy link

muradm commented Apr 15, 2022

Describe the bug
Currently metals gets bootstraped with coursier binary. However precompiled binaries provided by coursier are not running under Guix due to the nature of distribution and how it deals with linux ld loader.

When (lsp-install-server t 'metals) is executed on such environemnt, *Messages* will have:

LSP :: Download metals started.
(:download :url "https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz" :store-path "/home/muradm/.local/share/emacs/var/lsp/server/metals/coursier" :decompress :gzip :set-executable? t)
LSP :: Starting to download https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz to /home/muradm/.local/share/emacs/var/lsp/server/metals/coursier.gz...
Contacting host: github.com:443
Wrote /home/muradm/.local/share/emacs/var/lsp/server/metals/coursier.gz
LSP :: Finished downloading /home/muradm/.local/share/emacs/var/lsp/server/metals/coursier.gz...
LSP :: Decompressing /home/muradm/.local/share/emacs/var/lsp/server/metals/coursier.gz...
(Shell command succeeded with no output)
LSP :: Decompressed /home/muradm/.local/share/emacs/var/lsp/server/metals/coursier...
LSP :: Server metals install process failed with the following error message: (file-missing Doing vfork No such file or directory).
Check `*lsp-install*' and `*lsp-log*' buffer.

Below sequence of commands illustrating the issue with downloaded non-working launcher and working ls command as example.

$ wget https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz
$ gunzip cs-x86_64-pc-linux.gz
$ chmod a+x cs-x86_64-pc-linux
$ file cs-x86_64-pc-linux
cs-x86_64-pc-linux: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=ba800144eff305fab792b58743c6e5b9aaa50a46, for GNU/Linux 3.2.0, with debug_info, not stripped
$ ./cs-x86_64-pc-linux
bash: ./cs-x86_64-pc-linux: No such file or directory
$ ls -la /lib64/ld-linux-x86-64.so.2
ls: cannot access '/lib64/ld-linux-x86-64.so.2': No such file or directory
$ file $(readlink $(which ls))
/gnu/store/8fpk2cja3f07xls48jfnpgrzrljpqivr-coreutils-8.32/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, stripped
$ ls -la /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/ld-linux-x86-64.so.2
lrwxrwxrwx 1 root root 10 Jan  1  1970 /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/ld-linux-x86-64.so.2 -> ld-2.33.so

To Reproduce
Setup Guix, emacs for your liking and try (lsp-install-server t 'metals).

Expected behavior
Should be possible to use lsp-metals out-of-the-box.

In order to solve this issue, it could be better to use jar version of coursier launcher. It requires only java to be present in the system, which should be available any way. It will also simplify things for multiple platforms, as it should be running on any platform having java preinstalled.

Workaround
Dig lsp-metals to identify how coursier is used. Find emacs lsp server install path. Do the lsp-install-server work manually. For instance:

# for me lsp server install path is below
$ cd ~/.local/share/emacs/var/lsp/server/metals
$ wget https://github.com/coursier/launchers/raw/master/coursier.jar
$ java -jar coursier.jar bootstrap --java-opt -Xss4m --java-opt -Xms100m org.scalameta:metals_2.12:latest.release -r bintray:scalacenter/releases -r sonatype:snapshots -o metals
@kurnevsky
Copy link
Member

I have the same problem on nixos. But if you have coursier installed on your system it should work fine:

lsp-metals/lsp-metals.el

Lines 252 to 253 in 6980fb9

'(:system "cs")
'(:system "coursier")

Looks like coursier suggests to use native launchers by default: https://get-coursier.io/docs/cli-installation#native-launcher but I'm not sure whether it makes sence in our case - we will need jvm anyway to launch metals.

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

2 participants