I want to use "nix-shell" command

Environment

Ubuntu18.04

Install nix-daemon

sh <(curl https://nixos.org/nix/install) --daemon

Command

nix-shell -p cowsay

Error

nix-shell: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

Try and Error

$ which nix-shell

/root/.nix-profile/bin/nix-shell

$ ldd /root/.nix-profile/bin/nix-shell

libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fc1abb1b000)

$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib/x86_64-linux-gnu/

$ nix -shell -p cowsay

nix-shell: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29’ not found (required by /nix/store/ddmmzn4ggz1f66lwxjy64n89864yj9w9-nix-2.3.3/lib/libnixstore.so)

nix-shell: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29’ not found (required by /nix/store/86p38lq2y9a57j1yi8zkfy9xp6avsgny-brotli-1.0.7-lib/lib/libbrotlienc.so.1)

Do you have any ideas thatI have to do ?

1 Like

This is not right. It should be something like /nix/store/.... It seems you have LD_LIBRARY_PATH set, which is probably causing the problem. What do you have for LD_LIBRARY_PATH?

Thanks for your reply.

echo $LD_LIBRARY_PATH

/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu/

does this help ?

It’s probably what’s messing things up because Nix comes with its own set of libraries and binaries and LD_LIBRARY_PATH is forcing the Nix binaries to look for libraries at locations.

Unsetting it or making it empty should make Nix stuff work.

This particular LD_LIBRARY_PATH looks kind of weird because it seems to refer to system libraries, which is not what I’m used to. But I’m not familiar with distributions so I’m not sure.

1 Like