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

Error while loading shared libraries #2

Closed
d4hines opened this issue May 19, 2021 · 9 comments
Closed

Error while loading shared libraries #2

d4hines opened this issue May 19, 2021 · 9 comments

Comments

@d4hines
Copy link

d4hines commented May 19, 2021

Hi!
Great work on this script - it was really easy to implement.

But, something about my recent changes to NixOS configuration broke it. I now get the following error:

[2021-05-19 15:19:45.849] sh: uname: command not found
[2021-05-19 15:19:45.849] 
[2021-05-19 15:19:45.849] 
[2021-05-19 15:19:45.849] 桳›湵浡㩥挠浯慭摮渠瑯映畯摮
[2021-05-19 15:19:45.850] Launching C:\Windows\System32\wsl.exe -d NixOS sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" 054a9295330880ed74ceaedda236253b4f39a335 stable .vscode-server 0  '}
[2021-05-19 15:19:46.096] Setting up server environment: Looking for /home/nixos/.vscode-server/server-env-setup. Found, executing...
[2021-05-19 15:19:46.096] == '~/.vscode-server/server-env-setup' SCRIPT START ==
[2021-05-19 15:19:46.096] Got vscode directory : /home/nixos/.vscode-server
[2021-05-19 15:19:46.096] If the directory is incorrect, you can hardcode it on the script.
[2021-05-19 15:19:46.096] Patching nodejs binaries...
[2021-05-19 15:19:46.397] Patching /home/nixos/.vscode-server/bin/054a9295330880ed74ceaedda236253b4f39a335/node
[2021-05-19 15:19:46.398] error: getting status of '/mnt/c/Program Files/Microsoft VS Code/nixpkgs.stdenv.cc.cc.lib': No such file or directory
[2021-05-19 15:19:46.435] == '~/.vscode-server/server-env-setup' SCRIPT END ==
[2021-05-19 15:19:46.435] WSL version: 5.4.72-microsoft-standard-WSL2 NixOS
[2021-05-19 15:19:46.435] WSL2-shell-PID: 18548
[2021-05-19 15:19:46.435] Starting server: /home/nixos/.vscode-server/bin/054a9295330880ed74ceaedda236253b4f39a335/server.sh  --port=0 --use-host-proxy --without-browser-env-var --print-ip-address --enable-remote-auto-shutdown  
[2021-05-19 15:19:46.435] /home/nixos/.vscode-server/bin/054a9295330880ed74ceaedda236253b4f39a335/node: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
[2021-05-19 15:19:46.435] VS Code Server for WSL closed unexpectedly.
[2021-05-19 15:19:46.435] For help with startup problems, go to
[2021-05-19 15:19:46.435] https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips
[2021-05-19 15:19:46.436] C:\Windows\System32\wsl.exe -d NixOS -e kill 18548
[2021-05-19 15:19:46.512] WSL Daemon exited with code 0

I think this is the most interesting line:

error: getting status of '/mnt/c/Program Files/Microsoft VS Code/nixpkgs.stdenv.cc.cc.lib': No such file or directory

Maybe I need to disable interop?

@sonowz
Copy link
Owner

sonowz commented May 20, 2021

Hi, thank you for sharing the issue!

I think this line does not work in your environment:

patchelf --set-interpreter \"\$(cat \$NIX_CC/nix-support/dynamic-linker)\" --set-rpath \"\$(nix eval --raw nixpkgs.stdenv.cc.cc.lib)/lib/\" \"\$versiondir\"\"node\"

where nix eval --raw nixpkgs.stdenv.cc.cc.lib command should print something like /nix/store/c10296m7xgm3ksibcklb2xf48jr635x3-gcc-9.3.0-lib,
but in your case it printed /mnt/c/Program Files/Microsoft VS Code/nixpkgs.stdenv.cc.cc.lib.
You can write down the command and test in your NixOS terminal.

I suspect you have overridden stdenv package in your OS configuration, which would mess up something.

@sonowz
Copy link
Owner

sonowz commented May 20, 2021

The quick and dirty way would be hardcoding gcc path. In other words, replace \$(nix eval --raw nixpkgs.stdenv.cc.cc.lib)/lib/ from the script with actual gcc path.

You can find the path with the following command: find /nix/store -name libstdc++.so.6

@d4hines
Copy link
Author

d4hines commented May 24, 2021

It actually looks like stdenv.cc.cc.lib is missing entirely from my nix environment in the new configuration, even though I can find it in the nix store.

❯ nix eval --raw nixpkgs.stdenv.cc.cc.lib
error: getting status of '/home/d4hines/nixpkgs.stdenv.cc.cc.lib': No such file or directory

❯ find /nix/store -name libstdc++.so.6
/nix/store/9ilyrqidrjbqvmnn8ykjc7lygdd86g7q-gcc-10.2.0-lib/lib/libstdc++.so.6
/nix/store/xsqxamd86mh21dk0b775acaqgdijgf6p-gcc-10.2.0-lib/lib/libstdc++.so.6
/nix/store/hxs99j1kx878pxxw5lbdarml69r5f1qb-gcc-9.3.0-lib/lib/libstdc++.so.6
/nix/store/z5l2fm9byiz5yr82iznkv2rynr85ajnv-gcc-10.2.0-lib/lib/libstdc++.so.6

I wonder if this is because I'm using flakes. nix-env -i gcc works when I'm not using flakes, but not when I'm using flakes. For reference, I'm trying to use https://github.com/divnix/devos, and my configuration is here: https://github.com/d4hines/devos/tree/hope

Contrasted to the old, working configuration:

$ nix eval --raw nixpkgs.stdenv.cc.cc.lib
/nix/store/hxs99j1kx878pxxw5lbdarml69r5f1qb-gcc-9.3.0-lib

$ find /nix/store -name libstdc++.so.6
/nix/store/9ilyrqidrjbqvmnn8ykjc7lygdd86g7q-gcc-10.2.0-lib/lib/libstdc++.so.6
/nix/store/xsqxamd86mh21dk0b775acaqgdijgf6p-gcc-10.2.0-lib/lib/libstdc++.so.6
/nix/store/hxs99j1kx878pxxw5lbdarml69r5f1qb-gcc-9.3.0-lib/lib/libstdc++.so.6
/nix/store/z5l2fm9byiz5yr82iznkv2rynr85ajnv-gcc-10.2.0-lib/lib/libstdc++.so.6

@blaggacao
Copy link

Looking at the script, it's internal api towards the nix cli is based on the stable version of nix.

Questions regarding identifiers like:

  • What is binutils or patchelf?
  • What is nixpkgs?

... are resolved by querying information from NIX_PATH (or the defaults).

So for this script to work, roughly two conditions have to be met:

  1. nix cli of the environment in which this script is executed needs to be api compatible
  2. NIX_PATH must resolve the correct nixpkgs

@sonowz
Copy link
Owner

sonowz commented May 26, 2021

I think noting the challenges of using vscode remote-WSL with NixOS, would help.

  • Basically, what the script (or patchelf) does is simply static linking nodejs binary file, which defaults to dynamic linking the libstdc++.so.6.
  • And this should be done every time vscode remote-WSL is launched, since new nodejs binary is created every time vscode gets updated.

One way to do above 2 things, is using special server-env-setup file, which this repository uses. If there's another way to do them, it would work without serious issues.

@sonowz
Copy link
Owner

sonowz commented Aug 24, 2021

Another solution for vscode other than this repository was implemented recently.
It seems like the solution works in the same manner as mine, yet easier to debug errors.
I think it's worth trying :)

@sonowz
Copy link
Owner

sonowz commented Aug 24, 2021

Alright, nevermind the comment right above.
Today I updated my NixOS configuration using flakes, and run into the same error described here.

The cause was: the brand new Nix (which introduces flakes) changes how nix eval command works, so it didn't output anything.

I created a new script which works with the new Nix. Check out here. It should work.

@d4hines
Copy link
Author

d4hines commented Aug 25, 2021

Nice! Thanks for working on this.

@sonowz
Copy link
Owner

sonowz commented Oct 13, 2021

Seems like the issue is solved, closing the issue.

@sonowz sonowz closed this as completed Oct 13, 2021
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

3 participants