Fork me on GitHub
#calva
<
2021-08-30
>
Magnus Bareid12:08:13

hey hey! i'm having a problem with Clojure Language Server trying to start up, hoping someone here might know an answer 🙂 i'm working • in VSCode • remote-ssh'ed onto a Raspberry Pi 2 • Calva extension installed on the remote (also using leiningen &amp; OpenJDK 11.0.12 on the remote; all these mirror my local computer) • Clojure language server fails to start up, with output:

[Error - 12:46:36] Connection to server is erroring. Shutting down server.
/home/pi/.vscode-server/extensions/betterthantomorrow.calva-2.0.210/clojure-lsp: 1: /home/pi/.vscode-server/extensions/betterthantomorrow.calva-2.0.210/clojure-lsp: Syntax error: ")" unexpected
• only the language server fails; repls seem to work fine! has someone here encountered this before, perhaps? my googling has yielded little thus far. i'm happy to provide more output if desired!

ericdallo12:08:00

You are using probably a wrong clojure-lsp binary, and there is no binary for aarch64 yet :/

ericdallo12:08:35

Feel free to open an issue on clojure-lsp asking that support

Magnus Bareid12:08:29

ah, that would explain it, indeed - thanks!

Magnus Bareid12:08:07

technically, the Raspberry Pi 2 in question here is 32bit, but i'm guessing that there's even less demand for a clojure-lsp on that architecture 😛

ericdallo12:08:18

There is a workaround for now, download the clojure-lsp file from https://github.com/clojure-lsp/clojure-lsp/releases/tag/2021.08.24-14.41.56, which is a embedded jar, so you just need java on PATH

ericdallo12:08:37

then on calva settings point to that downloaded clojure-lsp

Magnus Bareid12:08:42

cool! but looking at the files, it looks like it's intended for 64-bit, right? i so it would probably not work like that, would it? i mean, i can try, of course, just want to cull my expectations

ericdallo12:08:19

that embedded jar is a java jar in a executable file, so it should work in everything that runs java fine

ericdallo12:08:37

it's not as fast as graalvm binary, but should be enough for you

Magnus Bareid12:08:53

awesome! going ahead with attempt now

borkdude13:08:16

graalvm doesn't support aarch64 32 bit, only 64bit

👍 1
Magnus Bareid13:08:07

oh, so basically, Calva's language server implementation relies specifically on graal?

ericdallo13:08:37

Calva language server implementation = https://clojure-lsp.github.io/clojure-lsp/ it generates native binaries for most used OS

ericdallo13:08:27

Windows, Linux, MacOS ATM, if you don't use any of these, the embedded jar is the fallback

Magnus Bareid13:08:19

so, i've put both the clojure-lsp.jar into the folder where Calva expected to find it (and also its companion clojure-lsp binary file, just to be sure) then i have set the remote vscode's setting "calva.clojureLspPath": "~/.vscode-server/extensions/betterthantomorrow.calva-2.0.210/clojure-lsp.jar" , and i also previously have made sure that the system's path has a JAVA_HOME pointing to OpenJDK's java binary but still, it doesn't work :thinking_face: did i miss something?

ericdallo13:08:54

you don't need the clojure-lsp.jar, the clojure-lsp one already has the jar embedded in the file.

Magnus Bareid13:08:17

right, i also tried using that in the settings, as well

ericdallo13:08:35

you should set to somthing like: "calva.clojureLspPath": "/path/to/clojure-lsp"

ericdallo13:08:05

can you try running clojure-lsp --version with tthat downloaded binary and check if it's working?

Magnus Bareid13:08:44

yeah, already tried that^ 😕

[Error - 14:39:39] Starting client failed
Launching server using command ~/.vscode-server/extensions/betterthantomorrow.calva-2.0.210/clojure-lsp failed.
and clojure-lsp --version only yields bash: clojure-lsp: command not found but if the binary is somehow made with graalvm, which requires 64-bit architecture- it would make sense that clojure-lsp can't function properly on a 32-bit system anyway, even with its jarfile included

borkdude13:08:03

why is this even a binary and not just a jar file?

borkdude13:08:30

for clj-kondo I offer an LSP server as a .jar file

Magnus Bareid13:08:43

that's what came with the vscode extension, so i've tried to use both, one at a time

Magnus Bareid13:08:56

calva, specifically

borkdude13:08:13

the vscode extension for clj-kondo should work independently from calva, it just uses java

borkdude13:08:23

but lsp is recommended of course

borkdude13:08:25

you could maybe download the jar file and then make a bash script which does java -jar the-jar.jar and then set that as the "lsp binary"

Magnus Bareid13:08:08

yeah, when i downloaded the source code of the binaries mentioned up above (simply called "clojure-lsp"), i saw that it even uses clj-kondo

borkdude13:08:11

#!/usr/env/bin bash java -jar the-jar.jar

ericdallo13:08:07

the clojure-lsp from the releases, is a embedded jar, which means is a executable that calls a java -jar on its file, is just a easy way for you to doesn't need to java -jar

ericdallo13:08:24

or you can download clojure-lsp.jar and do the java -jar yourself

Magnus Bareid13:08:50

then i noticed that you were the author of clj-kondo (@U04V15CAJ), so that was cool 😉 wouldn't it be easier, though, if i somehow just disabled Calva's lsp? and used clj-kondo instead?

ericdallo13:08:53

is just that before graalvm everyone was using the clojure-lsp one as it's easy as ./clojure-lsp and you just need java installed

ericdallo13:08:24

> if i somehow just disabled Calva's lsp? You will lose a lot of features, not sure it's possible as well on Calva

borkdude13:08:51

@UKFSJSM38 the bash script suggestion + downloaded jar should work right?

yes 1
borkdude13:08:03

perhaps this can be documented as a last resort option

ericdallo13:08:06

> and `clojure-lsp --version` only yields > bash: clojure-lsp: command not found Is this the output of the downloaded clojure-lsp from the releases page?

Magnus Bareid13:08:37

hang on, i might have derped about which terminal/folder i was in when i tried that

ericdallo13:08:38

yeah, this was never a issue since it's pretty simple 😅 but we can if is not clear

Magnus Bareid14:08:07

^ no, i was right, while in bash in the correct folder; i either get error from bash for alias not existing or permission denied if i try to run it as an executable

borkdude14:08:33

@UKFSJSM38 that's not what I meant

ericdallo14:08:55

@U02AQ7MGEQ1 the docs say to chmod +x the downloaded clojure-lsp to avoid the permission error

borkdude14:08:56

a user should just be able to write a bash script and use the normal jar, no weird shit with embedded stuff, as that's what's likely causing the trouble

ericdallo14:08:54

I agree if that is causing the issue, but I never saw an issue with the clojure-lsp embedded jar

borkdude14:08:04

have you ever tested it on aarch64 though?

Magnus Bareid14:08:03

regarding "place it in your $PATH with chmod 755"; do they mean to edit the /etc/environment file with sudo, or ... ?

Magnus Bareid14:08:26

however, the chmod +x (thanks for reminding me!) made the file executable, and so we got this instead

ericdallo14:08:48

so it worked, but clojure-lsp jar uses 2G of ram

ericdallo14:08:59

not enough for your device it seems :/

Magnus Bareid14:08:18

hahaha, i should have known!

Magnus Bareid14:08:37

ahhh, that's actually extremely funny to our project

borkdude14:08:37

that amount of memory is only needed for initial analysis though I think?

borkdude14:08:53

could it be less when the batch-size is less?

ericdallo14:08:03

we already tried decreasing that without success even with the batch size

Magnus Bareid14:08:04

having discussed arm32 vs arm64 multiple times over and over, because graalvm was very attractive (but now apparently also the increased memory on each of the corresponding alternatives) could be attractive as well

ericdallo14:08:11

I'm open to suggestions though

Magnus Bareid14:08:01

hey, crazy thought - could i use my local VSCode's resources to run the lsp, even though the codebase is on the remote?

borkdude14:08:17

I think the extensions always run on the remote machine

borkdude14:08:31

if you're using the ssh thing

borkdude14:08:39

but it's worth a try

borkdude14:08:08

what you could also do is open your project locally, but connect to a REPL on the machine

borkdude14:08:10

don't use the jack-in stuff

borkdude14:08:20

open the REPL on the machine and then connect to a remote running REPL from your local editor

☝️ 1
borkdude14:08:34

CIDER also has some stuff to translate remote paths to local paths

borkdude14:08:40

check their docs

Magnus Bareid14:08:25

thanks, it's worth a try indeed! :)