As a Windows 10 user, I want to use Nix to manage packages in my "Bash on Ubuntu on Windows" environment.
I follow the Nix installation instructions, which is bash <(curl https://nixos.org/nix/install)
, but I get an error: cannot execute binary file: Exec format error
. See "Steps to reproduce", below.
It seems the "nix-store" binary can't be executed. I did readelf -a $NIX_STORE
, which shows the following summary at the top:
(Moved from nixpkgs issue: https://github.com/NixOS/nixpkgs/issues/17915)
After installing "Bash on Ubuntu on Windows", enter a bash shell and execute the Nix installation command to see the following results:
alex@ALEX-CARBON:/mnt/c/Users/Alex$ bash <(curl https://nixos.org/nix/install)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2590 100 2590 0 0 5121 0 --:--:-- --:--:-- --:--:-- 5118
downloading Nix binary tarball for x86_64-linux from 'https://nixos.org/releases/nix/nix-1.11.2/nix-1.11.2-x86_64-linux.tar.bz2' to '/tmp/nix-binary-tarball-unpack.3ZltkRNJp1'...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
37 67.1M 37 25.0M 0 0 403k 0 0:02:50 0:01:03 0:01:47 729k
100 67.1M 100 67.1M 0 0 531k 0 0:02:09 0:02:09 --:--:-- 524k
performing a single-user installation of Nix...
copying Nix to /nix/store...........................
initialising Nix database...
/tmp/nix-binary-tarball-unpack.3ZltkRNJp1/unpack/nix-1.11.2-x86_64-linux/install: line 58: /nix/store/4z8srway6dl128dxzn5r0wwdvglz3m61-nix-1.11.2/bin/nix-store: cannot execute binary file: Exec format error
/tmp/nix-binary-tarball-unpack.3ZltkRNJp1/unpack/nix-1.11.2-x86_64-linux/install: failed to initialize the Nix database
uname -a
: Linux ALEX-CARBON 3.4.0+ #1 PREEMPT Thu Aug 1 17:06:05 CST 2013 x86_64 x86_64 x86_64 GNU/LinuxAn important thing to note is that even if it served a proper binary, it wouldn't work because Nix currently doesn't work on Windows. I tracked it down to a failing prctl
call in util.cc. But that's for another issue...
I heard that nix binaries have a custom ELF interpreter (aka the dynamic linker) which the Windows Linux subsystem doesn't yet support.
This has been fixed by Microsoft in the latest Windows Insider builds.
Most helpful comment
This has been fixed by Microsoft in the latest Windows Insider builds.