`GLIBC_2.33` not found, although it is installed

I recently updated my nixos channel to a newer commit and now java cannot find the correct glibc version.

/nix/store/fq78qsw0gg4frrmxpy40kacm2cxnz34c-jetbrains-jdk-11.0.10-b1427/lib/openjdk/bin/java: /nix/store/ikl21vjfq900ccbqg1xasp83kadw6q8y-glibc-2.32-46/lib/libc.so.6: version `GLIBC_2.33' not found (required by /nix/store/lg104nh0szci8slz5z6494m457jm5y3p-gcc-10.3.0-lib/lib/libstdc++.so.6)

For some reason it sees the previous version instead.
However, the correct version is actually installed on my system, which can be seen when running

$ ldd --version
ldd (GNU libc) 2.33

What can I do to fix it? I had the same problem when running the rust compiler, but I was able to fix that by installing the glibc package gobally.

You can either restart your computer, so that your system loads the newer glibc version first, or use LD_PRELOAD to load the other glibc before loading the program.

The root of the issue is that glibc only can load older versions of glibc, since your base current-system had an older version, but trying to load a newer version, there’s no guarantee that it will work for all cases. So it fails.

As per Any way for LD_LIBRARY_PATH to *not* break nix-env's absolute paths for dynamic libs · Issue #902 · NixOS/nix · GitHub another possible workaround without having to restart is to unset the LD_LIBRARY_PATH environmental variable.