How to deal with `/lib64/ld-linux-x86-64.so.2` missing on NixOS?

I’m trying to run julia on NixOS, and I just came across an issue where calling Plots.mp4(anim, "foobar.mp4") errors out because the julia Plots.jl package brings in its own ffmpeg binary to ~/.julia/artifacts/7f40eeb66d90d3026ae5fb68761c263b57adb840/bin/ffmpeg and it doesn’t seem to be compatible with NixOS. Running this binary I get,

$ ./ffmpeg
bash: ./ffmpeg: No such file or directory

Ok, so what does file have to say?

$ file ffmpeg
ffmpeg: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.4.0, stripped

So as best as I can tell the issue is that /lib64/ld-linux-x86-64.so.2 doesn’t exist on NixOS systems.

What’s the recommended workaround for these scenarios? I’m open to hacky-ish ideas…

EDIT: created an issue on the Plots.jl project here: https://github.com/JuliaPlots/Plots.jl/issues/3271

1 Like

I built GitHub - Mic92/nix-ld: Run unpatched dynamic binaries on NixOS to cope with this. See the two examples on how to use it.

4 Likes

The alternative is fhsuserenv. You can find a few examples here: https://github.com/nix-community/nix-environments/

2 Likes

Packaging/Binaries - NixOS Wiki gives you some general knowledge on the topic. As well as autopatchelf - what it can look like | Farid Zakaria’s Blog and GitHub - Lassulus/nix-autobahn

2 Likes

Thank you so much @Mic92! This is all super helpful.

I followed all the tutorials to try to get this working for Cypress on my nixos setup but it still doesn’t work. For the

NIX_LD_LIBRARY_PATH = lib.makeLibraryPath [
    stdenv.cc.cc
    # ...
  ];

when I do ldd $(which Cypress) , I get

linux-vdso.so.1 (0x0000ffffba9f5000)
	libc.so.6 => /nix/store/6afvzgx3himw7584k9zmfxmqd86b1z7j-glibc-2.34-210/lib/libc.so.6 (0x0000ffffba826000)
	/nix/store/l0y717pj7ds1agfpzrlz4zq112hnpjqq-glibc-2.34-210/lib/ld-linux-aarch64.so.1 => /nix/store/6afvzgx3himw7584k9zmfxmqd86b1z7j-glibc-2.34-210/lib/ld-linux-aarch64.so.1 (0x0000ffffba9c2000)

How do I know what library to put in the list from that result ? glibc ??

If you just depend on libc.so.6, you are already covered. When using nix-ld, you need to set the NIX_LD environment variable. This will determine which glibc library loader to load. The library loader will take care of providing the libc it was compiled together with. This because a library loader will share a lot of internal state with the libc and the two need to be compatible.

1 Like
Hosted by Flying Circus.