Glibc 2.33 vs 2.34 Rust Madness

We are building Rust software in nix-shell. Our Rust is from nixpkgs-unstable. Recently nixpkgs-unstable seems to have switched to glibc 2.34, which causes sadness if the underlying system is using glibc 2.33 (like NixOS 21.11 or Ubuntu). This results in errors like these:

error: /nix/store/qjgj2642srlbr59wwdihnn66sw97ming-glibc-2.33-123/lib/ undefined symbol: __libc_siglongjmp, version GLIBC_PRIVATE
   --> /home/julian/.cargo/registry/src/
284 | pub use proc_macro_error_attr::proc_macro_error;
    |         ^^^^^^^^^^^^^^^^^^^^^


error: /lib/x86_64-linux-gnu/ version `GLIBC_2.33' not found (required by /home/peter/Development/particle/ws/target/debug/deps/
   --> /home/snuernberger/.cargo/registry/src/
284 | pub use proc_macro_error_attr::proc_macro_error;
    |         ^^^^^^^^^^^^^^^^^^^^^

If we use nix-shell --pure and clean up all ~/.cargo and target folders, things work, but this is a pretty drastic solution. Most of us want to leak some things from the environment into their nix-shell for productivity.


have you considered just using fenix? It’s a lot easier to keep up with the latest rust releases and I’ve never had any issues like this. It’s pretty convenient to ensure that the exact rust toolchain used by your project is always available directly from your shell.

1 Like

You can export LD_PRELOAD to force the use of the nixpkgs glibc everywhere in the shell.

Related, perhaps: github-runner impure environment · Issue #169812 · NixOS/nixpkgs · GitHub

I’ve had this exact problem while using fenix - and the problem goes away without it. So I don’t think switching to it is the right suggestion.

I’m actually quite unclear why this happens with flakes - aren’t they supposed to be hermetic? What is leaking from the host’s environment?

I stand corrected on my comment above: it was not the usage of fenix that caused the issue, but the fact that I mixed two different versions of nixpkgs: one was the pinned nixpkgs input in the flake (fenix.inputs.nixpkgs), the other passed into the a derivation as the pkgs argument. Turns out that those brought in two different versions of glibc, which caused the problem.