Installation directly results in seg faults for any nix command

Hi all,

I am using Ubuntu 22.04 LTS.
I had previously tried installing nix via a different method and saw no direct issues with nix other than possibly some paths not being properly included for my end-goal (which is use of the software nain4 found here: GitHub - jacg/nain4: An API that makes it easier to write Geant4 application code.). At least nix commands functioned.
I tried to uninstall because I did not initially follow the specific software package instructions for a nix installation (tried below) and wanted to start fresh.

I then followed the multi-user removal instructions found here:
https://nixos.org/manual/nix/stable/installation/uninstall

Actual commands:
sudo systemctl stop nix-daemon.service
sudo systemctl disable nix-daemon.socket nix-daemon.service
sudo systemctl daemon-reload
sudo rm -rf /etc/nix /etc/profile.d/nix.sh /etc/tmpfiles.d/nix-daemon.conf /nix ~root/.nix-channels ~root/.nix-defexpr ~root/.nix-profile
for i in $(seq 1 32); do
sudo userdel nixbld$i
done
sudo groupdel nixbld

then removing references to nix in:

/etc/bash.bashrc
/etc/bashrc
/etc/profile
/etc/zsh/zshrc
/etc/zshrc

Rebooted, then re-installed nix with the bash command (just following instructions here):
curl --proto ‘=https’ --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s – install

This successfully completed with no warnings, errors, or input from me.
However, usage of any nix command in a new terminal, such as:
nix-build --version

Output:
Segmentation fault (core dumped)

I have no idea if I missed something in the initial nix removal that is now causing a conflict? Are there further nix dependencies outside of those listed in the removal instructions that I need to remove before the determinate installation stops looking for things that may not exist?

EDIT: at this point this error seems to be true for any nix binary installer, not just the determinate systems one

I’m not sure, but we can start gathering info:

  • output of uname -a
  • Does it run if you try to run it in a ~clean environment? maybe like env -i $(type -p nix-build) --version? If that works:
    • Does your shell session have any LD_* variables set? I’m not sure if any of those can cause a segfault, but IIRC they’re a semi-common cause of fresh installs not working. Method of checking depends a bit on your shell, but in bash I can do something like compgen -A variable "LD_" or declare -p | grep " LD_"

uname -a gives:
Linux pc-620 6.2.0-37-generic #38~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 2 18:01:13 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

running in the clean env does in fact return the nix version:
nix (Nix) 2.18.1

I do have the LD_LIBRARY_PATH set, i checked via printenv, it is set to:
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/local/include/geant4_install/lib:/usr/local/include/geant4_install/lib:/usr/lib/x86_64-linux-gnu

trying the compgen command doesn´t seem to find the LD_* variable though

I imagine that’s it. Can you confirm by unsetting it and see if Nix runs?

I’m not sure why it’s set on your system, but New install: Nix wants glibc 2.38, Debian 12 has 2.36 - #5 by TLATER is a recent example of a similar problem ~solved by unsetting this env.

the command ‘unset’ did not seem to do the trick, but export LD_LIBRARY_PATH=“” successfully removed it and allowed nix to run

thanks for troubleshooting with me