Nix: Nix Installation Failure on "Bash on Ubuntu on Windows"

Created on 23 Aug 2016  路  4Comments  路  Source: NixOS/nix

Issue description

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:

  • Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  • Class: ELF64
  • Data: 2's complement, little endian
  • Version: 1 (current)
  • OS/ABI: UNIX - System V
  • ABI Version: 0
  • Type: EXEC (Executable file)
  • Machine: Advanced Micro Devices X86-64
  • Version: 0x1
  • Entry point address: 0x407770
  • Start of program headers: 64 (bytes into file)
  • Start of section headers: 149120 (bytes into file)
  • Flags: 0x0
  • Size of this header: 64 (bytes)
  • Size of program headers: 56 (bytes)
  • Number of program headers: 9
  • Size of section headers: 64 (bytes)
  • Number of section headers: 31
  • Section header string table index: 28

(Moved from nixpkgs issue: https://github.com/NixOS/nixpkgs/issues/17915)

Steps to reproduce

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

Technical details

  • System:
    ** Windows 10 Pro, Version 1607, OS Build 14393.51, System type 64-bit OS, x64-based CPU (Intel Core i5-5200U)
    ** 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/Linux
  • Nix version: Latest installation script

Most helpful comment

This has been fixed by Microsoft in the latest Windows Insider builds.

All 4 comments

An 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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Infinisil picture Infinisil  路  3Comments

copumpkin picture copumpkin  路  3Comments

ihsanturk picture ihsanturk  路  3Comments

bryanhuntesl picture bryanhuntesl  路  3Comments

eqyiel picture eqyiel  路  3Comments