Leonardo Monteiro
Leonardo Monteiro

Reputation: 101

Java: symbol lookup error: /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0: undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE

I've been working on a Java project that uses a gui.jar file to import some classes. Everything was working fine until yesterday. Now, I can compile the .class files by the command

javac -d ./bin -sourcepath ./src -classpath ./bin/gui.jar src/simulation/TestSimulateur.javac

but when I try to execute the program with

java -classpath bin:bin/gui.jar simulation.TestSimulateur

I get the error

java: symbol lookup error: /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0: undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE make: *** [Makefile:47: carte1] Error 127

I don't know much about how snap and the libraries work so I'm not sure about the root of the problem. It's strange that the problem only appears when I run it on VSCode, while it works fine if I run it on the normal Linux terminal.

I've searched a lot but couldn't find how to solve the problem. As I've said, I'm newbie on Linux system. Between my attempts, I tried to reinstall VSCode, updating the system and updating snap packages, but none of those worked.

Upvotes: 10

Views: 14611

Answers (3)

Frank N
Frank N

Reputation: 10376

I got this error message /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0: undefined symbol:

on my freshly installed (freshly but plenty of packages) Ubuntu 24 (no MATE, no nana) on numerous applications, i.e. dconf-editor.

sudo snap remove code

resolved the problem (instantly, in same terminal window, as well as in new terminal window (relevant as far as updated env vars might go)

Reinstalling

sudo snap install code --classic

... and things kept working. (Again, same terminal and fresh termin). So yeah, the old did-you-turn-it-off-and-on-again joke…

Upvotes: 0

AmeyaVS
AmeyaVS

Reputation: 1034

Though I have already answered it here

The issue with how the VSCode Snap package libraries are configured to be used. They are setting the following environment variable GTK_PATH, which gets inherited by the VSCode Terminal.

Unsetting the environment variable in the VSCode terminal does seem to work for me.

unset GTK_PATH

As a slightly more permanent workaround, you can also unset GTK_PATH in your VS Code user settings, run "Preferences: Open User Settings (JSON)" and add this to your settings.json:

    "terminal.integrated.env.linux": {
        "GTK_PATH": ""
    }

Update 2: 2024-03-09

It seems the VSCode Snap package(version 1.87.1) has introduced even more environment variables for GTK Toolkit.

I have to additionally unset the following environment variables for additional GTK Built Applications:

unset GIO_MODULE_DIR

For people looking at solving this issue with the VSCode Snap Package installation can use the following in their settings.json:

"terminal.integrated.env.linux": {
    "GTK_PATH": null,
    "GIO_MODULE_DIR": null,
},

Upvotes: 33

Baole Fang
Baole Fang

Reputation: 81

I've also encountered this bug after a recent ubuntu update. I think this is related to the snap and vscode.

One simple solution is to uninstall vscode in snap with

sudo snap remove code

Then, install vscode with apt shown in https://code.visualstudio.com/docs/setup/linux

sudo apt install ./<file>.deb

Upvotes: 8

Related Questions