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-channel --update' stopped working on nix-2.2.1: error: while setting up the build environment: getting attributes of path '': No such file or directory #2673

Closed
trofi opened this issue Feb 9, 2019 · 12 comments
Labels

Comments

@trofi
Copy link
Contributor

trofi commented Feb 9, 2019

The install is a nix install on Gentoo (not a NixOS).

$ nix-channel --update --verbose
downloading 'https://nixos.org/channels/nixpkgs-unstable'...
downloading 'https://releases.nixos.org/nixpkgs/nixpkgs-19.03pre168678.54dcb0b1376/binary-cache-url'...
unpacking channels...
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
error: while setting up the build environment: getting attributes of path '': No such file or directory
error: program '/usr/bin/nix-env' failed with exit code 1

I tried strace-ing nix-env and running nix-daemon but I did not find where that '' path comes from. Can nix be improved to dump more information on where that path comes from?

Some version info:

$ nix --version
nix (Nix) 2.2.1
$ nix-channel --list
nixpkgs https://nixos.org/channels/nixpkgs-unstable

ottidmes on #nixos linked me to a thread about /bin/sh out of nix: https://logs.nix.samueldr.com/nixos/2019-02-06#1938291

Working workaround:

$ nix-build '<nixpkgs>' -A bash
$ sudo systemctl restart nix-daemon
@trofi
Copy link
Contributor Author

trofi commented Feb 11, 2019

Found out today it was not completely working workaround. I got to the failure:

I built nix from source and did not pass --with-sandbox-shell=... option to ./configure. Unfortunately instead of bailing out nix built the following sandbox path:

$ nix show-config | fgrep sandbox
...
sandbox-paths = /bin/sh=

I worked around it locally by passing --with-sandbox-shell=/bin/busybox to ./configure.

To make problem harder to encounter I suggest to:

  1. fail ./configure if --with-sandbox-shell= is not passed or default to /bin/sh
  2. mention 'source' part fo sandbox-path when mounting onto target fails

Thanks!

@dtzWill
Copy link
Member

dtzWill commented Feb 13, 2019

fail ./configure if --with-sandbox-shell= is not passed or default to /bin/sh

This certainly seems in the territory of nix doctor if build-time check isn't preferred for whatever reason.
Truth is that in common usage Nix builders kinda really expect a /bin/sh to exist and probably have sane behavior in basic cases :).

Offhand 2) just seems like an omission---likely because it doesn't happen very often. Anyway, mentioning source sounds great, good idea!

@pmiddend
Copy link

Note that the Gentoo ebuild still seems to be broken. When updating, I get this error:

while setting up the build environment: executing '/bin/bash': No such file or directory
builder for '/nix/store/4birxpr75haj1mpw81ix5bw78lyj273r-nixpkgs-19.09pre174594.0c0954781e2.drv' failed with exit code 1
error: build of '/nix/store/4birxpr75haj1mpw81ix5bw78lyj273r-nixpkgs-19.09pre174594.0c0954781e2.drv' failed
error: program '/usr/bin/nix-env' failed with exit code 100

@trofi
Copy link
Contributor Author

trofi commented Apr 11, 2019

Please report it to http://bugs.gentoo.org/ and we'll try to sort out your problem.

@renatoGarcia
Copy link
Member

I'm having this same problem on ArchLinux with nix 2.2.2, and at least one more person it's having it too (https://aur.archlinux.org/packages/nix/#comment-690619).
At first the path was empty:

$ nix show-config | grep sandbox
...
sandbox-paths = /bin/sh=

Then I have recompiled it with each of:

--with-sandbox-shell=/bin/sh
--with-sandbox-shell=/bin/bash
--with-sandbox-shell=/bin/busybox
--with-sandbox-shell=/nix/store/r7gk5w5i5qq4j44aazl4dbmvjn5p8v1c-busybox-1.29.2/bin/busybox
--with-sandbox-shell=/nix/store/6v88ick1cxnn5g91m8qrrqww0lrlr27x-bash-4.4-p23/bin/bash

With the last option, for instance the error is now:

nix-channel --update
unpacking channels...
while setting up the build environment: executing '/usr/bin/bash': No such file or directory
builder for '/nix/store/x2nwwcsq3z1czh1kw2r83pl5ihbh6c54-nixpkgs-19.03.172361.cf3e277dd0b.drv' failed with exit code 1
error: build of '/nix/store/x2nwwcsq3z1czh1kw2r83pl5ihbh6c54-nixpkgs-19.03.172361.cf3e277dd0b.drv' failed
error: program '/usr/bin/nix-env' failed with exit code 100

@renatoGarcia
Copy link
Member

Removing the Arch package, the previous /nix, and installing through curl https://nixos.org/nix/install | sh I was able to get a working nix again.
I have not solved the problem, but I'm able to work on nix again for now.

@asppsa
Copy link

asppsa commented May 7, 2019

@renatoGarcia, I've fixed the Nix package in Arch Linux now by adding a bit of complex build-sandbox-paths = ... logic.

For others who are trying to work this out, the full set of scripts that you might need are listed in .../share/nix/corepkgs/config.nix (where ... is /usr for me). You need versions of all of these (including a number of coreutils packages: I think just env, mkdir and mv) that are either statically linked, or are installed from Nix. I've gone for the latter approach using a script to download the necessary packages from the most recent NixOS release.

I also tried to use busybox, but it seems that shell provided by busybox is not full-featured enough.

@edolstra
Copy link
Member

edolstra commented May 8, 2019

This problem should go away once #2748 is merged. It makes nix-channel use a built-in derivation that doesn't require any additional paths in the sandbox.

gentoo-bot pushed a commit to gentoo/gentoo that referenced this issue Oct 10, 2019
Fix `nix-channel --update` does not work on freshly-installed nix.

`nix-channel --update` does a few main things:
1. fetch new tarball with nix expressions
2. unpack that tarball as part of the build system using
   a shell script derived by unpack-channel.nix.
3. install the result into /nix/store

[2.] fails because tarball unpacking runs in a sandboxed environment
in a container with /nix/store and /bin/sh mounted.

unpack-channel.nix needs bash, tar and xz binaries in PATH.
These are normally provided by bash, tar and xz packages from /nix/store.

Unfortunately bash, tar and xz packages are not yet fetched as we
only have nix installed without nixpkgs tree.

1. we patch unpack-channel.nix to only require 'sh'
2. we use /bin/sh as a static busybox and point nix at it:
   ./configure --with-sandbox-shell=/bin/busybox

Reported-by: Kirill Zaborsky
Closes: https://bugs.gentoo.org/693482
Bug: NixOS/nix#2673
Package-Manager: Portage-2.3.76, Repoman-2.3.17
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
@drewboardman
Copy link

I'm still seeing this issue, or similar:

https://github.com/NixOS/nixpkgs/issues/78714

@stale
Copy link

stale bot commented Feb 16, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Feb 16, 2021
@klarkc
Copy link

klarkc commented Nov 14, 2021

This problem should go away once #2748 is merged. It makes nix-channel use a built-in derivation that doesn't require any additional paths in the sandbox.

Still not working, I've just tested in Arch with nix 2.3.16-1

@stale stale bot removed the stale label Nov 14, 2021
@stale stale bot added the stale label Aug 12, 2022
@trofi
Copy link
Contributor Author

trofi commented Oct 29, 2023

Let's close it as obsolete as 2.4 and later should behave a bit better.

@trofi trofi closed this as completed Oct 29, 2023
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

8 participants