nix-bundle icon indicating copy to clipboard operation
nix-bundle copied to clipboard

nix bundle'd executables do not work, fail with nix-user-chroot: No such file or directory

Open arianvp opened this issue 4 years ago • 3 comments

Original issue: https://github.com/NixOS/nix/issues/4426

Describe the bug

I used nix bundle to build a standalone executable; however the executable doesn't work

Steps To Reproduce

$ nix bundle nixpkgs#hello
$ ldd hello
	not a dynamic executable
$ ./hello world
./nix/store/m6mcsf66rn5hc6s8n8yfb8rknxzvcwqh-startup: line 2: ./nix/store/j0rfffzsih095w4nvl6cp0zbmdiaycfs-nix-user-chroot-2c52b5f/bin/nix-user-chroot: No such file or directory

Expected behavior the hello executable starts up as expected

nix-env --version output

nix (Nix) 2.4pre20201201_5a6ddb3

Additional context

Add any other context about the problem here.

arianvp avatar Jan 13 '21 11:01 arianvp

I can't reproduce it. Can you try running:

$ ./hello --extract
$ tree dat/

matthewbauer avatar Jan 24 '21 02:01 matthewbauer

Hey, since I've got a very similar issue, I thought I might as well just ask here. The package hello works for me without any issues, I'm trying to bundle up neuron. So I do nix-bundle neuron /bin/neuron which successfully creates an executable without dynamic linkage. Invoking it, however, yields:

λ ~/swap/ ./neuron
execvp(/nix/store/4v2cx37r17mrj7vnggm8cpn52jvbwz06-neuron-7.5/bin/neuron): No such file or directory

So, as you've suggested, I did a ./neuron --extract and here is the full output of the tree command: termbin.com/5v0m

The error kind of makes sense, since the path to neuron on my system is /nix/store/0phih22b8amy44a4zqydh68nsy2jsjvs-neuron-1.9.29.0/bin/neuron

DasNaCl avatar Jun 04 '21 12:06 DasNaCl

I met the same problem when I inspected the binary:

$ ldd r8jyb7lzfrj73f3kjxvks86yb7q1wd3k-nix-user-chroot-2c52b5f/bin/nix-user-chroot 
        linux-vdso.so.1 (0x00007ffd25345000)
        libstdc++.so.6 => not found
        libm.so.6 => /nix/store/vjq3q7dq8vmc13c3py97v27qwizvq7fd-glibc-2.33-59/lib/libm.so.6 (0x00007fdcb4e6d000)
        libgcc_s.so.1 => /nix/store/vjq3q7dq8vmc13c3py97v27qwizvq7fd-glibc-2.33-59/lib/libgcc_s.so.1 (0x00007fdcb4e53000)
        libc.so.6 => /nix/store/vjq3q7dq8vmc13c3py97v27qwizvq7fd-glibc-2.33-59/lib/libc.so.6 (0x00007fdcb4c8e000)
        ./nix/store/vjq3q7dq8vmc13c3py97v27qwizvq7fd-glibc-2.33-59/lib/ld-linux-x86-64.so.2 => /nix/store/vjq3q7dq8vmc13c3py97v27qwizvq7fd-glibc-2.33-59/lib64/ld-linux-x86-64.so.2 (0x00007fdcb4fb0000)

Adding -static-libstdc++ into Makefile solves my problem.

nix-bundle = pkgs.nix-bundle.overrideAttrs (attrs: {
  postInstall = attrs.postInstall + ''
    sed -i "s/g++/g++ -static-libstdc++/" $out/share/nix-bundle/nix-user-chroot/Makefile
  '';
});

gjz010 avatar Mar 03 '22 14:03 gjz010