I have nuked /nix and want to reinstall, but I am hitting this:
~ $ sh <(curl https://nixos.org/nix/install)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2476 100 2476 0 0 13604 0 --:--:-- --:--:-- --:--:-- 13679
downloading Nix 2.2.2 binary tarball for x86_64-linux from 'https://nixos.org/releases/nix/nix-2.2.2/nix-2.2.2-x86_64-linux.tar.bz2' to '/tmp/nix-binary-tarball-unpack.LHXqrSJPiN'...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 22.5M 100 22.5M 0 0 5437k 0 0:00:04 0:00:04 --:--:-- 5584k
Note: a multi-user installation is possible. See https://nixos.org/nix/manual/#sect-multi-user-installation
performing a single-user installation of Nix...
directory /nix does not exist; creating it by running 'mkdir -m 0755 /nix && chown jojo /nix' using sudo
copying Nix to /nix/store.................................
initialising Nix database...
installing 'nix-2.2.2'
building '/nix/store/2c4l83wkdfrj7ra9k07l0aqvym1d5z20-user-environment.drv'...
created 6 symlinks in user environment
Fatal error: glibc detected an invalid stdio handle
Aborted
Installation is obviously only partial.
Maybe related: #2733.
This is a Debian unstable system, with libc6-2.28-5.
Installing 2.2.1 via
sh <(curl https://nixos.org/releases/nix/nix-2.2.1/install)
works.
I believe I encountered the same issue, and that the 2.2.1 fix above also works.
I was running the install in a docker container using centos:latest.
Update: the 2.2.1 fix above does not work for me; the installation completes, but sourcing the profile script does not yield working nix-* commands. It seems to work as-is using a Debian base
ENV MYUSER=somebody
RUN useradd -ms /bin/bash ${MYUSER} && \
echo "${MYUSER} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${MYUSER} && \
chmod 0440 /etc/sudoers.d/${MYUSER}
RUN mkdir -p /etc/nix && echo 'sandbox = false' > /etc/nix/nix.conf
USER $MYUSER
ENV USER $MYUSER
RUN curl https://nixos.org/nix/install | sh
...
I've run into the same problem just now on Debian Buster. Interestingly this method of installation does not work:
curl https://nixos.org/nix/install | sh
but this one does:
sh <(curl https://nixos.org/releases/nix/nix-2.2.2/install)
though both should install the same version of nix.
I get this error non-deterministically. I am installing the exact same version of Nix into a brand-new Vagrant machine, and it fails with this error some percentage of the time.
The version I'm installing is 2.2.2. I'm not using either of the curl or bashisms, but transferring the file to the server and running it directly. (Well, I'm doing it via ansible, but same thing.)
Further info: The VM is Centos 7, and i'm disabling sandboxing since user namespacing isn't enabled by default there.
Last bit of info: I ran the installer 100 times in a row, and I hit this problem 4 times (4%).
They all look the same as OP's report, except for a bit of extra info at the end. Maybe it's nix-channel that is the source of the error?
downloading Nix 2.2.2 binary tarball for x86_64-linux from 'https://moria.staging.relexsolutions.com/v1.0.0/resource/nix-installer/ver/2.2.2-x86_64-linux' to '/tmp/nix-binary-tarball-unpack.NzgN4EHqCG'...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r100 7849 0 7849 0 0 8430 0 --:--:-- --:--:-- --:--:-- 8430\r100 15.3M 0 15.3M 0 0 8378k 0 --:--:-- 0:00:01 --:--:-- 8378k\r100 22.5M 0 22.5M 0 0 10.5M 0 --:--:-- 0:00:02 --:--:-- 10.5M
Note: a multi-user installation is possible. See https://nixos.org/nix/manual/#sect-multi-user-installation
performing a single-user installation of Nix...
copying Nix to /nix/store.................................
initialising Nix database...
Nix: creating /home/nixsrv/.nix-profile
installing 'nix-2.2.2'
building '/nix/store/2c4l83wkdfrj7ra9k07l0aqvym1d5z20-user-environment.drv'...
created 6 symlinks in user environment
Fatal error: glibc detected an invalid stdio handle
/tmp/nix-binary-tarball-unpack.NzgN4EHqCG/unpack/nix-2.2.2-x86_64-linux/install: line 142: 22943 Aborted $nix/bin/nix-channel --update nixpkgs
If the problem really is with nix-channel, then this is effectively solved in 2.3 via b9567aa8b6f935522d1037377e0e5205a7529fd8, which makes nix-channel --update errors non-fatal.
diff --git a/scripts/install-nix-from-closure.sh b/scripts/install-nix-from-closure.sh
index ab20774b..62f7cb67 100644
--- a/scripts/install-nix-from-closure.sh
+++ b/scripts/install-nix-from-closure.sh
@@ -138,7 +138,10 @@ if ! $nix/bin/nix-channel --list | grep -q "^nixpkgs "; then
$nix/bin/nix-channel --add https://nixos.org/channels/nixpkgs-unstable
fi
if [ -z "$_NIX_INSTALLER_TEST" ]; then
- $nix/bin/nix-channel --update nixpkgs
+ if ! $nix/bin/nix-channel --update nixpkgs; then
+ echo "Fetching the nixpkgs channel failed. (Are you offline?)"
+ echo "To try again later, run \"nix-channel --update nixpkgs\"."
+ fi
fi
Yeah, I think this is solved in 2.3. I reran the installer another 100 times and got zero failures.
This is a dup of https://github.com/NixOS/nix/issues/2733 and can be closed.
Most helpful comment
Installing 2.2.1 via
works.