6

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.

2 Answers2

13

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": ""
    }
AmeyaVS
  • 814
  • 10
  • 26
  • unsetting from vscode terminal didn't work for me. but when i added it in launch.json (as mentioned in the other answer) it worked! – Reyno Apr 08 '23 at 11:53
  • Are you launching a debug/task from VSCode UI? – AmeyaVS Apr 08 '23 at 11:55
  • yes for debugging and breakpoints. so basically I'm using F5 (or run > start debugging) – Reyno Apr 08 '23 at 13:14
  • 1
    @Reyno, you could try setting the environment variable to be empty in the `setting.json`. That should also help in resolving it for now. – AmeyaVS Apr 08 '23 at 14:52
  • Thanks @AmeyaVS, that worked as simple as it is. It still gives me a lot of warnings but at least it compiles. Would you mind clearing more or less where the bug comes from and how this solve the problem? – Leonardo Monteiro Apr 12 '23 at 10:01
  • 1
    @LeonardoMonteiro, this bug is a manifestation of the VSCode Snap Package specifying the `GTK_PATH` environment variable within the script in VSCode which is inherited in the Terminal Process in VSCode. You can find relevant discussion [here](https://github.com/microsoft/vscode/issues/179274). – AmeyaVS Apr 12 '23 at 15:43
4

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
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
Baole Fang
  • 41
  • 1