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

libstdc++.so.6 from GCC requires GLIBC_2.33 but gets linked with glibc-2.32 #138821

Closed
pshirshov opened this issue Sep 21, 2021 · 20 comments
Closed
Labels
0.kind: bug 6.topic: java Including JDK, tooling, other languages, other VMs

Comments

@pshirshov
Copy link
Contributor

pshirshov commented Sep 21, 2021

JNI libraries which need libstdc++.so.6 fail to load under IntelliJ IDEA.
Seems like something is wrong with gcc package or the way LD_LIBRARY_PATH is defined in the jetbrains formula.

Error messages look like

 java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: /tmp/librocksdbjni18325293990181609010.so: 
/nix/store/jsp3h3wpzc842j0rz61m5ly71ak6qgdn-glibc-2.32-54/lib/libc.so.6: version `GLIBC_2.33' not found 
(required by /nix/store/vyqnqbp3yczrzjx2byk6p680q3mzanyw-gcc-10.3.0-lib/lib/libstdc++.so.6)

A quick search over the issues shows that other people experience similar linking issues with other software:

  1. [20.03] rstudio is broken #85921 (comment)
  2. Mangohud not worked #134679 (comment)

etc

At the same time everything works in FHS environments, for some reason glibc version is correct there:

❯ ls -la /usr/lib|grep libc
lrwxrwxrwx    79 nobody nogroup  1 Jan  1970  libc-2.33.so -> /nix/store/4ikqdj43z39bchjfr462izwbh2w3nbnm-javaenv-usr-target/lib/libc-2.33.so

I'm not sure if this problem is related to IDEA or stdenv/gcc, but I noticed that the formula for Android Studio uses FHS env, maybe IDEA should do that as well?

@prusnak prusnak added the 6.topic: java Including JDK, tooling, other languages, other VMs label Sep 21, 2021
@Artturin
Copy link
Member

How to repro?

@veprbl
Copy link
Member

veprbl commented Sep 22, 2021

Likely a duplicate of #84043

@pshirshov
Copy link
Contributor Author

How to repro?

Install intellij idea, create a simple java/kotlin/scala project trying to initialize rocksdb and run it. I may provide a test project if necessary.

@Ma27
Copy link
Member

Ma27 commented Sep 22, 2021

I'm not really sure if that'll trigger the problem. There is an issue template for a reason though. Please provide the information that's requested in there.

@pshirshov
Copy link
Contributor Author

Oh, don't worry, it definitely will.

nix-info output:

❯ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.13.16, NixOS, 21.11 (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.4pre20210908_3c56f62`
 - channels(root): `"nixos-21.11pre317242.bc9b956714e, home-manager"`
 - channels(pavel): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

I'm not sure if it would help anyone if I re-format the issue report according to the template, so I would probably leave it as is.

@Ma27
Copy link
Member

Ma27 commented Sep 22, 2021

OK, I see :) Would you mind creating such a simple project if possible? That'd speed up the reproduction significantly for me :)

@pshirshov
Copy link
Contributor Author

I'm unable to reproduce the problem directly in the shell:

~ on ☁️  (eu-west-1) took 1m47s
❯ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/nix/store/0kiykyrnrpfhmjwxwx89kxr20hmf5304-gcc-10.3.0-lib/lib/

~ on ☁️  (eu-west-1)
❯ export _JAVA_OPTIONS="-Djava.library.path=`pwd`"

~ on ☁️  (eu-west-1)
❯ jshell
Picked up _JAVA_OPTIONS: -Djava.library.path=/home/pavel
|  Welcome to JShell -- Version 11.0.12
|  For an introduction type: /help intro

jshell> System.loadLibrary("rocksdbjni-linux64");

jshell>

But a project under IDEA, doing exactly the same thing, fails. Possibly the issue is not related to IDEA itself but something is wrong with graalvm formula.

I'll make a repro.

@pshirshov
Copy link
Contributor Author

Actually I guess the most interesting question is why do I have two glibc versions in my system? I believe that shouldn't be possible with nix versioning model?..

@pshirshov
Copy link
Contributor Author

Well, the problem is solved. Wrong glibc version had been pulled by home-manager.

@t-chab
Copy link

t-chab commented Oct 21, 2021

@pshirshov : how did you solved it ? I have the same issue with IntelliJ and I'm also using home-manager

@Artturin
Copy link
Member

check your channels

@t-chab
Copy link

t-chab commented Oct 21, 2021

@Artturin : they seems fine to me, but perhaps I miss something, I'm a nix noob 🥵

image

@Artturin
Copy link
Member

Artturin commented Oct 21, 2021

sudo nix-channel --list to list your root channels
if there is a nixos channel then you shouldn't have a nixpkgs channel in your user channels nix-channel --remove nixpkgs

@t-chab
Copy link

t-chab commented Oct 21, 2021

@Artturin : I don't have any nixos root channel. I'm currently using Nix installed on an Ubuntu 20.04 LTS

image

@Artturin
Copy link
Member

do you have packages installed with nix-env?(other than home-manager) if so remove them
nix-env -q to list them
nix-env -e name

@t-chab
Copy link

t-chab commented Oct 21, 2021

Only two :
image

Should I remove nix ?

@Artturin
Copy link
Member

not sure but probably not.

try garbage collecting nix-collect-garbage --delete-older-than 1m

@t-chab
Copy link

t-chab commented Oct 23, 2021

@Artturin : I now have a slighty different message, and I wonder if the problem is not related to an ubuntu package ?

Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 28, in <module>
    from CommandNotFound import CommandNotFound
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
    from CommandNotFound.db.db import SqliteDatabase
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
    import apt_pkg
ImportError: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /nix/store/7fv9v6mnlkb4ddf9kz1snknbvbfbcbx0-gcc-10.3.0-lib/lib/libstdc++.so.6)

because after purging ubuntu package command-not-found I no longer have the issue.

Thanks a lot for your help.

@coderfromhere
Copy link

coderfromhere commented Nov 1, 2021

How was this fixed? I don't use home-manager and I hven't installed anything with nix-env, still I'm getting the same GLIBC_2.33 not found error on my pure nix builds:

nix-build: /nix/store/jsp3h3wpzc842j0rz61m5ly71ak6qgdn-glibc-2.32-54/lib/libc.so.6: version `GLIBC_2.33' not found (required by /nix/store/7fv9v6mnlkb4ddf9kz1snknbvbfbcbx0-gcc-10.3.0-lib/lib/libstdc++.so.6)
make: *** [Makefile:113: build] Error 1

UPD: I've found the issue. My Nix shell was using the LD_LIBRARY_PATH hack explained in https://nixos.wiki/wiki/Packaging/Quirks_and_Caveats under the section ImportError: libstdc++.so.6: cannot open shared object file: No such file to fix certain issues with discoverability in interpreted langauges, and this was causing the above GLIBC_2.33 exception. Everything works if I remove the LD_LIBRARY_PATH fixed prefix.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/proper-setup-for-python-development-with-nix-and-vs-code/19011/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 6.topic: java Including JDK, tooling, other languages, other VMs
Projects
None yet
Development

No branches or pull requests

10 participants