Eugleo / magic-racket

The best coding experience for Racket in VS Code
https://marketplace.visualstudio.com/items?itemName=evzen-wybitul.magic-racket
GNU General Public License v3.0
199 stars 29 forks source link

Connection with langserver lost (Ubuntu) #105

Closed brvtalcake closed 1 year ago

brvtalcake commented 1 year ago

Environment

Error message

From "Racket Language Client"

[Info  - 6:11:27 AM] Connection to server got closed. Server will restart.
[Info  - 6:11:27 AM] Connection to server got closed. Server will restart.
[Info  - 6:11:27 AM] Connection to server got closed. Server will restart.
[Info  - 6:11:27 AM] Connection to server got closed. Server will restart.
[Error - 6:11:27 AM] Connection to server got closed. Server will not be restarted.

Additional context

I previously installed the extension on my laptop where it worked, so I wanted to install it on my desktop. I installed it the same way, following all the instructions, and for some reasons it did'nt work (I had the error message above). First I tried to reinstall the langserver, and for some other reasons I had another message after reinstalling it (that I partially forgot, but that was something related to an unresolved symbol in libpthread.0, not even located in some raco nor racket (nor /usr/bin) directory, but in the snap one, i.e where I have only vscode and its extensions (well actually not only vscode but and its extensions, but only vscode but and its extensions when speaking about things that could be related to the bug)).

Then I tried to completely reinstall everything :

And I ran into the same error than the first one.

jryans commented 1 year ago

Hmm, I wonder if there's some sandboxing involved that's getting in the way...

What happens when you run racket -l racket-langserver in a terminal? Does it just give a blank line (ready to receive input) or some kind of error?

brvtalcake commented 1 year ago

The langserver seems to be ready to receive an input :

Screenshot from 2023-04-03 15-52-22

jryans commented 1 year ago

Hmm, how about if you try the same in a VS Code terminal (which presumably applies the same paths and sandboxing as the extension)?

Did you change the language server command in Magic Racket settings to something other than the default perhaps?

brvtalcake commented 1 year ago

It does the same thing in VSCode's terminal. I didn't change anything after I installed it, but I just tried to change the path to /snap/bin/racket to see what could happen, but it's the same error

EDIT : I also tried to rearrange the options passed to racket to start the language server, but the output remains the same

jryans commented 1 year ago

From looking around at past issues like this, it seems to typically be related to a missing dynamic library that Racket / the Racket GUI framework needs.

brvtalcake commented 1 year ago

The only one that seems related is this one. However, I'm not on macOS nor installed it via asdf. Nevertheless I tried running

$ raco pkg update --auto racket-lib
$ raco pkg update --auto main-distribution

And I had this for both :

Inferred package scope: installation
open-output-file: error opening file
  path: /snap/racket/current/usr/share/racket/pkgs/.LOCKpkgs.rktd
  system error: Read-only file system; errno=30
  context...:
   /snap/racket/current/usr/share/racket/collects/racket/private/kw-file.rkt:134:2: call-with-output-file*
   /snap/racket/current/usr/share/racket/collects/racket/file.rkt:752:0: call-with-file-lock
   /snap/racket/current/usr/share/racket/collects/pkg/main.rkt:327:16
   body of (submod "/snap/racket/current/usr/share/racket/collects/pkg/main.rkt" main)
   /snap/racket/current/usr/share/racket/collects/raco/raco.rkt:41:0
   body of "/snap/racket/current/usr/share/racket/collects/raco/raco.rkt"
   body of "/snap/racket/current/usr/share/racket/collects/raco/main.rkt"

I also tried raco pkg update --all :

00: Resolving "mcfly" via https://download.racket-lang.org/releases/8.7/catalog/
01: Resolving "chk-lib" via https://download.racket-lang.org/releases/8.7/catalog/
02: Resolving "chk" via https://download.racket-lang.org/releases/8.7/catalog/
03: Resolving "html-parsing" via https://download.racket-lang.org/releases/8.7/catalog/
04: Resolving "chk-doc" via https://download.racket-lang.org/releases/8.7/catalog/
05: Resolving "racket-langserver" via https://download.racket-lang.org/releases/8.7/catalog/
03: Resolving "html-parsing" via https://pkgs.racket-lang.org
04: Resolving "chk-doc" via https://pkgs.racket-lang.org
00: Resolving "mcfly" via https://pkgs.racket-lang.org
02: Resolving "chk" via https://pkgs.racket-lang.org
01: Resolving "chk-lib" via https://pkgs.racket-lang.org
05: Resolving "racket-langserver" via https://pkgs.racket-lang.org
Resolving "overeasy" via https://download.racket-lang.org/releases/8.7/catalog/
Resolving "overeasy" via https://pkgs.racket-lang.org
No updates available

Any advice on how to check for missing libs is welcome

jryans commented 1 year ago

Are you able to run the DrRacket GUI app? The langserver is effectively a headless DrRacket, so this may reveal missing libraries used by both.

brvtalcake commented 1 year ago

Are you able to run the DrRacket GUI app?

Yep, I can run it. And I can still use the language server in any terminal.

I managed to reinstall racket / raco via apt, and then the langserver (the same way I initally did), and here is the error I was speaking about (the second error I had) :

racket: symbol lookup error: /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0: undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE
[Info  - 9:42:59 PM] Connection to server got closed. Server will restart.
racket: symbol lookup error: /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0: undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE
[Info  - 9:43:00 PM] Connection to server got closed. Server will restart.
racket: symbol lookup error: /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0: undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE
[Info  - 9:43:00 PM] Connection to server got closed. Server will restart.
racket: symbol lookup error: /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0: undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE
[Info  - 9:43:01 PM] Connection to server got closed. Server will restart.
racket: symbol lookup error: /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0: undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE
[Error - 9:43:01 PM] Connection to server got closed. Server will not be restarted.

If I do something like nm /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0 | grep init, here is what I have :

0000000000015ec0 T cnd_init
                 U __ctype_init@@GLIBC_PRIVATE
                 U _dl_allocate_tls_init@@GLIBC_PRIVATE
00000000000161d0 t elision_init
000000000001dc08 d __frame_dummy_init_array_entry
000000000000d2e0 t __GI___pthread_mutexattr_init
000000000000a690 t __GI___pthread_mutex_init
0000000000006000 t _init
0000000000014dd0 t __init_sched_fifo_prio
                 U __libc_pthread_init@@GLIBC_PRIVATE
[...]

So yeah the symbol is effectively undefined.

Here is a related problem. I'll keep searching for an answer, maybe it's not related to magic-racket. Maybe this is related to racket or vscode ? And by the way thanks a lot for your help, I really appreciate.

EDIT : Here is another related problem (actually the same person, probably). But I would be happy to not have to uninstall all my snaps to see if it works, sooo yeah, would be happy to have another solution.

The strangest thing is that Racket (installed via apt, now, and initially) is complaining about a lib located in core20, in the snap dir. I'm not even sure if I could try to make it load "the good" lib, since it would require to have the one that was linked to the executable (or maybe I'm wrong ?)

jryans commented 1 year ago

Hmm, thanks for the additional detail on this. I only use Linux occasionally at the moment, so I am afraid I don't quite know what to suggest next here. I have heard of various Snap compatibility and sandboxing issues over the years, but I am not sure what the "correct" solution for this case would be.

brvtalcake commented 1 year ago

I'm trying to rebuild both Racket CS and Racket BC from source, without prebuilt packages. I'll tell you if it works better

brvtalcake commented 1 year ago

Finally, it appears that rebuilding Racket from source was the right way to go ! So that wasn't due to your extension. Hopefully it will help people in the same case though

jryans commented 1 year ago

Glad to hear that fixed it! 😄

Do you plan to report to the Ubuntu packaging team that their Racket is missing some dependencies? That may help others avoid this issue.

brvtalcake commented 1 year ago

Do you plan to report to the Ubuntu packaging team that their Racket is missing some dependencies?

To be honest, I don't even know if this really a missing dependency. But yes I can try to ask them and show them this issue to see if they can do something ! (But not today ! :sleeping:)

Anyway thank you for your help !