WSL: Unable to install Nix package manage
cloud@DESKTOP-DSHEB2Q:~$ curl https://nixos.org/nix/install | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2590 100 2590 0 0 362 0 0:00:07 0:00:07 --:--:-- 559
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.GBp1CD11La'...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 67.1M 100 67.1M 0 0 65098 0 0:18:01 0:18:01 --:--:-- 77956
performing a single-user installation of Nix...
directory /nix does not exist; creating it by running ‘mkdir -m 0755 /nix && chown cloud /nix’ using sudo
[sudo] password for cloud:
copying Nix to /nix/store...........................
initialising Nix database...
/tmp/nix-binary-tarball-unpack.GBp1CD11La/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.GBp1CD11La/unpack/nix-1.11.2-x86_64-linux/install: failed to initialize the Nix database
I don’t know what is running wrong, because is no useful information. WSL just complaint cannot execute binary file: Exec format error, using file command on this file I get
cloud@DESKTOP-DSHEB2Q:/nix/store/4z8srway6dl128dxzn5r0wwdvglz3m61-nix-1.11.2/bin$ file nix-store
nix-store: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped
To reproduce this error, simply run curl https://nixos.org/nix/install | sh or just follow the instruction on http://nixos.org/nix/. This will install a standalone package manager independent from the host. It heavily used link.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 15
- Comments: 18 (2 by maintainers)
I think this can be closed. I’ve installed Nix, did a normal build of GNU Hello and executed it. I then did a cross-compile from WSL to an
.exefile:And the brilliant thing is that an
.exewill work within WSL so it’s possible to execute Windows binaries within Nix builds! 🎆@domenkozar, I went through those steps and was able to launch python and didn’t see any obvious failures in the install spew. Please let us know if you hit any issues on the most recent insider build.
Sorry for the delay in looking at this thread, I dug into this a bit and it looks like our ELF parsing logic is assuming that interpreter paths must be less than 64 characters long, which is incorrect. When I bumped that number up to 128 the Nix binaries are running. I’m going to look through the ELF format documentation to determine what the correct max size is (maybe it’s just PATH_MAX).
Unfortunately shortly after the Nix binaries use the PR_SET_PDEATHSIG option of the prctl system call for which I’ve filed a task to implement.
https://github.com/Microsoft/BashOnWindows/issues/471#issuecomment-240223133
The precompiled executables are patched with
patchelfto set the path to the dynamic linker to/home/linuxbrew/.linuxbrew/lib/ld.soand RPATH to/home/linuxbrew/.linuxbrew/lib(by default). After being modified bypatchelfthese executables are no longer loadable by the Windows kernel.To reproduce the issue, install Linuxbrew (instructions at http://linuxbrew.sh) and run
Any update on this issue? Does this mean that Linuxbrew executables modified by
patchelfare also expected to work after this patch? See the related issue https://github.com/Microsoft/BashOnWindows/issues/471#issuecomment-240223133