Python3 and openjdk use different glibc (packaging jep fails)

Hello everyone,

I try to build the jep package, which is a a bridge library between java and python. The goal is in the end to try to make a polynote (notebook framework written in scala) service for NixOS. It has jep as a dependency:

First I build the package with: nix-build -A pythonPackage.jep

Then I try to run jep with this command from nixpkgs folder:

java -Djava.library.path=./result/lib/python3.8/site-packages/jep \
  -cp ./result/lib/python3.8/site-packages/jep/jep-3.9.1.jar \
 -jar ./result/lib/python3.8/site-packages/jep/jep-3.9.1.jar \

I get this error:

java.lang.UnsatisfiedLinkError: /nix/store/s78py3n2pzhiyi8qy9hwjngkv89n88qj-python3.9-jep-3.9.1/lib/python3.9/site-packages/jep/ /nix/store/9df65igwjmf2wbw0gbrrgair6piqjgmi-glibc-2.31/lib/ version `GLIBC_2.32' not found (required by /nix/store/0ipynhzs670xbc9hixy05wgfd2xad2v2-python3-3.9.0/lib/
        at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
        at java.base/java.lang.ClassLoader$NativeLibrary.load(
        at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(
        at java.base/java.lang.ClassLoader.loadLibrary0(
        at java.base/java.lang.ClassLoader.loadLibrary(
        at java.base/java.lang.Runtime.loadLibrary0(
        at java.base/java.lang.System.loadLibrary(
        at jep.MainInterpreter.initialize(
        at jep.MainInterpreter.getMainInterpreter(
        at jep.Jep.<init>(
        at jep.SharedInterpreter.<init>(
        at jep.Run.main(

I have tried with python 3.6 and python 3.7 using both openjdk 8 and openjdk 11, but none of these have matching glibc versions. This is a bit surprising to me. Is there a way to override the glibc version?

I also wonder how I actually set that only python3 should be used. I didn’t find any other way than using python3.pkgs.buildPythonPackage, that doesn’t feel correct.

I’m assuming some odd pinning is going on, because on unstable, it’s currently at glibc-2.32, and python3 points to python3.8 not python3.9

[10:40:01] jon@nixos ~/projects/nixpkgs (master)
$ ldd $(nix-build -A python39)/bin/python3.9 (0x00007ffff6b22000) => /nix/store/0ipynhzs670xbc9hixy05wgfd2xad2v2-python3-3.9.0/lib/ (0x00007f4573cf6000) => /nix/store/bdf8iipzya03h2amgfncqpclf6bmy3a1-glibc-2.32/lib/ (0x00007f4573cd5000) => /nix/store/bdf8iipzya03h2amgfncqpclf6bmy3a1-glibc-2.32/lib/ (0x00007f4573cd0000) => /nix/store/bdf8iipzya03h2amgfncqpclf6bmy3a1-glibc-2.32/lib/ (0x00007f4573c96000) => /nix/store/jxk39sgwpfnsfb00dsff5p96mxaj6m33-ncurses-6.2/lib/ (0x00007f4573c22000) => /nix/store/bdf8iipzya03h2amgfncqpclf6bmy3a1-glibc-2.32/lib/ (0x00007f4573c1b000) => /nix/store/bdf8iipzya03h2amgfncqpclf6bmy3a1-glibc-2.32/lib/ (0x00007f4573ad8000) => /nix/store/bdf8iipzya03h2amgfncqpclf6bmy3a1-glibc-2.32/lib/ (0x00007f4573abe000) => /nix/store/bdf8iipzya03h2amgfncqpclf6bmy3a1-glibc-2.32/lib/ (0x00007f45738fd000)
	/nix/store/bdf8iipzya03h2amgfncqpclf6bmy3a1-glibc-2.32/lib/ => /nix/store/bdf8iipzya03h2amgfncqpclf6bmy3a1-glibc-2.32/lib64/ (0x00007f45740ba000)

Also, when adding packages to python-modules, please follow

I also go over python packaging with nix in a video, located:

namely, you should not have python3 as an import, you should be importing the python packages individually. using the python3 package will fix the python interpreter to python3.8, which is likely why you’re hitting these issues.

1 Like

Thanks for the feedback!

I think I might mixed up pasting output from trying with python 3.9, whereas the sources are showing python 3.8. I think both python 3.8, and 3.9 required glibc 1.32, while openjdk uses 1.31 it seems.

I will read through the docs again and try more tomorrow :slightly_smiling_face:

Where does the java you’re executing the jar with come from? If it’s from your system and you’re e.g. on 20.09 you’ll have an openjdk here with glibc-2.31 (or in other words: you don’t have the one from your buildInputs).

To confirm my hypothesis can you please open a nix-shell with an openjdk from your branch (nix-shell -I nixpkgs=$(pwd) -p openjdk) and run the java -D... command from that shell?

master is, but AFAICS currently nixpkgs-unstable (and nixos-unstable) aren’t: - or am I looking at this the wrong way?

you’re probably right, I’ve largely abandoned channels as I’m constantly just using the branch to verify something works

Thanks a lot to everyone!

Yes @Ma27, you where right. I did use openjdk from my channel, and not from the branch I was in. Thank you for the tip of using nixpkgs=$(pwd) that solved the issue! Hehe, I should have thought about that, my nix skills are probably a bit rusty!

I encountered another issue now with java, but I think that is solvable.

1 Like