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

Build of Nix fails with error: home directory '/homeless-shelter' exists #11295

Open
noamraph opened this issue Aug 14, 2024 · 3 comments
Open
Labels

Comments

@noamraph
Copy link
Contributor

noamraph commented Aug 14, 2024

Describe the bug

When building Nix from a single-user installation, the build fails with the error: home directory '/homeless-shelter' exists; please remove it to assure purity of builds without sandboxing

This is probably related to #8313

Steps To Reproduce

This PR adds another GitHub Actions builder, which installs Nix with a single-user installation. It fails with this error: #11397

Alternatively:

  1. Use WSL2. I used both 22.04 and 24.04 and got this behavior.
  2. Install nix as a single user:
wget https://releases.nixos.org/nix/nix-2.24.2/nix-2.24.2-x86_64-linux.tar.xz
tar -xf nix-2.24.2-x86_64-linux.tar.xz
nix-2.24.2-x86_64-linux/install
. ~/.nix-profile/etc/profile.d/nix.sh
mkdir -p ~/.config/nix
echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
  1. Build nix itself:
nix build github:noamraph/nix/no-gc-auto-test

(noamraph/nix/no-gc-auto-test disables the gc-auto test, to overcome #11284.)

Expected behavior

Build succeeds.

Actual behavior

Build fails with this error:

error: builder for '/nix/store/sir91p2xxiqfjmsxz6a4mgb4ab7nlqi7-nix-2.25.0pre20240812_005d00f.drv' failed with exit code 2;
       last 25 log lines:
       >     ++(/build/source/tests/functional/common/vars-and-functions.sh:342) for arg in "$@"
       >     ++(/build/source/tests/functional/common/vars-and-functions.sh:343) [[ silly != \s\i\l\l\y ]]
       >     ++(/build/source/tests/functional/common/vars-and-functions.sh:379) command grep silly
       >     ++(./user-envs-test-case.sh:34) nix-env -qa '*' --system
       >     ++(./user-envs-test-case.sh:34) grepQuiet x86_64-linux
       >     ++(/build/source/tests/functional/common/vars-and-functions.sh:378) checkGrepArgs x86_64-linux
       >     ++(/build/source/tests/functional/common/vars-and-functions.sh:341) local arg
       >     ++(/build/source/tests/functional/common/vars-and-functions.sh:342) for arg in "$@"
       >     ++(/build/source/tests/functional/common/vars-and-functions.sh:343) [[ x86_64-linux != \x\8\6\_\6\4\-\l\i\n\u\x ]]
       >     ++(/build/source/tests/functional/common/vars-and-functions.sh:379) command grep x86_64-linux
       >     ++(./user-envs-test-case.sh:37) nix-env -i foo-1.0
       >     installing 'foo-1.0'
       >     this derivation will be built:
       >       /build/nix-test/user-envs/store/0askgxjd42ypg9wp2xn7w10g9hv4piw9-foo-1.0.drv
       >     error: home directory '/homeless-shelter' exists; please remove it to assure purity of builds without sandboxing
       >     +++(./user-envs-test-case.sh:37) onError
       >     +++(/build/source/tests/functional/common/vars-and-functions.sh:292) set +x
       >     user-envs.sh: test failed at:
       >       source in ./user-envs-test-case.sh:37
       >       main in user-envs.sh:5
       > make: *** [mk/lib.mk:90: tests/functional/remote-store.sh.test] Error 1
       > make: *** [mk/lib.mk:90: tests/functional/user-envs.sh.test] Error 1
       > ran test tests/functional/experimental-features.sh... [PASS]
       > ran test tests/functional/lang.sh... [PASS]
       > ran test tests/functional/fetchMercurial.sh... [PASS]
       For full logs, run 'nix log /nix/store/sir91p2xxiqfjmsxz6a4mgb4ab7nlqi7-nix-2.25.0pre20240812_005d00f.drv'.

nix-env --version output

nix-env (Nix) 2.24.2

Additional context

When disabling sandbox the build succeeds:

nix --option sandbox false build github:noamraph/nix/no-gc-auto-test

When applying a branch which uses /sys/homeless-shelter instead of /homeless-shelter the build succeeds:

nix --option sandbox false build github:noamraph/nix/homeless-shelter-to-sys
/nix/store/zya5clc153x2ainifgs3gqrz9w3rvqrl-nix-2.25.0pre20240812_afcd0ff/bin/nix build github:noamraph/nix/no-gc-auto-test

Priorities

Add 👍 to issues you find important.

@puckipedia
Copy link
Contributor

Why is it that the test fails? Even when disabling the sandbox, you still shouldn't be able to create $HOME, unless you're root, in which case, ...why are you running builds as root?

@noamraph
Copy link
Contributor Author

Hi, I'm not running the build as root. I described the exact steps to reproduce in the issue.

Interestingly, it wasn't reproduced on an Ubuntu 24.04 running on VirtualBox, but I did reproduce it by running the exact steps on a GitHub Actions worker.

@noamraph
Copy link
Contributor Author

noamraph commented Sep 2, 2024

I added another way to reproduce the problem: This PR adds another GitHub Actions builder, which installs Nix with a single-user installation. It fails with this error: #11397

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

2 participants