Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
arianvp opened this issue Jan 13, 2021 · 3 comments

Comments

@arianvp
Copy link
Member

arianvp commented Jan 13, 2021

Original issue: NixOS/nix#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.

@matthewbauer
Copy link
Member

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

$ ./hello --extract
$ tree dat/

@DasNaCl
Copy link

DasNaCl commented Jun 4, 2021

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

@gjz010
Copy link

gjz010 commented Mar 3, 2022

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
  '';
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants