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

Pill Nr.10 make command not found because source builder.sh exits nix-shell #125

Open
ThoenigAdrian opened this issue Jan 24, 2020 · 3 comments
Labels

Comments

@ThoenigAdrian
Copy link

ThoenigAdrian commented Jan 24, 2020

In Pill Nr.10 it says:

You may get an error in the installation phase, because the user may not have the permission to write to /nix/store
It didn't install, but it built.
We're able to cd into hello-2.10 and type make, because now it's available.

Well for me this isn't true, because it says make: command not found

[jane@nixos:~/empty]$ nix-shell hello.nix

[nix-shell:~/empty]$ ls
autotools.nix builder.sh hello-2.10 hello-2.10.tar.gz hello.nix

[nix-shell:~/empty]$ make
make: command not found

[nix-shell:~/empty]$ source builder.sh
/nix/store/svc70mmzrlgq42m9acs0prsmci7ksh6h-hello-2.10.tar.gz
[......]
/nix/store/9v78r3afqy9xn9zwdj9wfys6sk3vc01d-coreutils-8.31/bin/mkdir: cannot create directory '/nix/store/dwr4r7w7ayyzx3i7mb4gn1la57r2rsbc-hello2': Read-only file system
make[3]: *** [Makefile:1554: install-binPROGRAMS] Error 1
make[3]: Leaving directory '/home/jane/empty/hello-2.10'
make[2]: *** [Makefile:2377: install-am] Error 2
make[2]: Leaving directory '/home/jane/empty/hello-2.10'
make[1]: *** [Makefile:1878: install-recursive] Error 1
make[1]: Leaving directory '/home/jane/empty/hello-2.10'
make: *** [Makefile:2371: install] Error 2

[jane@nixos:~/empty]$ cd hello-2.10/

[jane@nixos:~/empty/hello-2.10]$ make
make: command not found

This is because somehow the nix shell exited together with the "source builder.sh"- command

You can see this because before it said [nix-shell] now it says [jane@nixos] .

I don't know enough about nix-shell to decide whether this is an issue with the tutorial or an issue with nix-shell.

If i comment the following lines:

#make
#make install
#find $out -type f -exec patchelf --shrink-rpath '{}' \; -exec strip '{}' \; 2>/dev/null

in the builder.sh I can use make afterwards presumably because the command isn't failing and therefore it doesn't drop me out of the nix-shell.

@jtojnar
Copy link
Member

jtojnar commented Jan 24, 2020

The builder.sh sets errexit shell option on the first line, making the shell exit on an error.

source shell builtin will run a script as if you manually ran the individual script lines in the active shell. So, unlike running it in a subprocess using bash ./buider.sh, the shell spawned using nix-shell will be the one running the commands and the one to exit.

I am not sure how it could have ever worked for anyone. Unless set -e was added to the builder after chapter 10 was written without updating it (but that does not seem to be the case looking at the commit history).

In nixpkgs, we use approach more similar to section 10.2. “A builder for nix-shell”, where we only source the setup part but not configure/make/install.

@ThoenigAdrian
Copy link
Author

Ok so it's an issue with the tutorial, thx for clarifying and for the explanation. Hopefully this can be fixed, so no one else stumbles across this.

@jtojnar jtojnar added the bug label Jan 24, 2020
@Intey
Copy link

Intey commented Aug 20, 2021

Solve this.
Has same issue, but with removing 2>/dev/null from find command gives me point, that the find command not found itself. So, i patch the baseInputs and add findutils to them.

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

No branches or pull requests

3 participants