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

error: while setting up the build environment: getting attributes of path '/etc/hosts': Permission denied #41651

Closed
magnetophon opened this issue Jun 7, 2018 · 22 comments

Comments

@magnetophon
Copy link
Member

I get the above error when I nixos-rebuild.

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.16.11, NixOS, 18.09pre140958.696c6bed4e8 (Jellyfish)
  • multi-user?: no
  • sandbox: yes
  • version: nix-env (Nix) 2.0.2
  • channels(bart): ""
  • channels(root): "nixos"
    warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
@ryantm
Copy link
Member

ryantm commented Jun 9, 2018

@magnetophon Can you provide a log of the nixos-rebuild and a copy of your configuration.nix file?

@magnetophon
Copy link
Member Author

@ryantm here is the config, and here's the log:

bash -x nixos-rebuild test -I nixpkgs=$NIXPKGS                                                                                                                                           [21:18:23]
+ '[' -x /nix/store/xn5gv3lpfy91yvfy9b0i7klfcxh9xskz-bash-4.4-p19/bin/bash ']'
+ export SHELL=/nix/store/xn5gv3lpfy91yvfy9b0i7klfcxh9xskz-bash-4.4-p19/bin/bash
+ SHELL=/nix/store/xn5gv3lpfy91yvfy9b0i7klfcxh9xskz-bash-4.4-p19/bin/bash
+ set -e
+ origArgs=("$@")
+ extraBuildFlags=()
+ action=
+ buildNix=1
+ fast=
+ rollback=
+ upgrade=
+ repair=
+ profile=/nix/var/nix/profiles/system
+ buildHost=
+ targetHost=
+ '[' 3 -gt 0 ']'
+ i=test
+ shift 1
+ case "$i" in
+ '[' test = dry-run ']'
+ action=test
+ '[' 2 -gt 0 ']'
+ i=-I
+ shift 1
+ case "$i" in
+ j=nixpkgs=/home/bart/source/nixpkgs/
+ shift 1
+ extraBuildFlags+=("$i" "$j")
+ '[' 0 -gt 0 ']'
+ '[' -z '' -a -n '' ']'
+ '[' '' = localhost ']'
+ '[' '' = localhost ']'
+ '[' -z test ']'
+ canRun=
+ '[' test = switch -o test = boot -o test = test ']'
+ canRun=1
+ '[' -n '' -a -z '' ']'
+ '[' -z '' ']'
+ export PATH=/nix/store/j86jzz7hmcy305xn6zx33933zshi2v2i-nix-2.0.2/bin:/home/bart/bin:/run/wrappers/bin:/home/bart/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/etc/profiles/per-user/bart/bin
+ PATH=/nix/store/j86jzz7hmcy305xn6zx33933zshi2v2i-nix-2.0.2/bin:/home/bart/bin:/run/wrappers/bin:/home/bart/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/etc/profiles/per-user/bart/bin
+ '[' -z '' -a -n 1 -a -z '' ']'
++ nix-build --no-out-link --expr 'with import <nixpkgs/nixos> {}; config.system.build.nixos-rebuild' -I nixpkgs=/home/bart/source/nixpkgs/
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
+ p=/nix/store/swlmjq8mjvpiibhjwx98dpgm785b9xwd-nixos-rebuild
+ export _NIXOS_REBUILD_REEXEC=1
+ _NIXOS_REBUILD_REEXEC=1
+ exec /nix/store/swlmjq8mjvpiibhjwx98dpgm785b9xwd-nixos-rebuild/bin/nixos-rebuild test -I nixpkgs=/home/bart/source/nixpkgs/
building Nix...
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
building the system configuration...
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
these derivations will be built:
  /nix/store/6hrl08b0ia0lvvvqvjxwv7hcgn25xrmj-guitarix2-0.37.1.tar.xz.drv
  /nix/store/0ly37fsnc9q7lz8smigwqj40c8l2bqg9-guitarix-0.37.1.drv
  /nix/store/gcbx6dqkbnsc9jkc14yf3mbdswr0rzn3-nixos-version.drv
  /nix/store/imzvfkm9r5n0vvbrayydpys2lfxw9d71-source.drv
  /nix/store/xjs1fvf3iwzsbl1408d66cpg9yprq1x2-xdg-utils-1.1.2.drv
  /nix/store/sv2r436b3992r5jpl19fr62lfcmqb1d7-system-path.drv
  /nix/store/1c46xr0w96h0q2afwfdd3l1d59clydjq-set-environment.drv
  /nix/store/1cljgc43nrnwr5rld7f8ppfdmav2w3f9-etc-zshenv.drv
  /nix/store/24m1pskvjad9bxin8clba0ijvwmlwylg-issue.drv
  /nix/store/f5rl254zrzsalq6wjy1apqimvc7w8slp-etc-profile.drv
  /nix/store/v126bhnq18kby5hn75769p1vip86s5q5-dbus-1.drv
  /nix/store/hr6sciqagjbhfclvhvyc341w8031ycy4-unit-dbus.service.drv
  /nix/store/n62zdk8q1dgd7ilpj56yzfa2lai3m126-unit-systemd-fsck-.service.drv
  /nix/store/zid39l515xnn7gigk483m9x53z90j0rn-unit-polkit.service.drv
  /nix/store/m0nm3dplapfqj0kmfkjnrjqd82sfw6r6-system-units.drv
  /nix/store/ifc24563dlx2him5hxfilhii6h42v26b-unit-emacs.service.drv
  /nix/store/qwspf8ibagapaza4amm3vpc0rw19fz0g-user-units.drv
  /nix/store/2wlh49cjv8ah81d6d9k8iag92n2x41zj-etc.drv
  /nix/store/gfdv5jrl8ax7xbm9x7b86i6ahkw3m1im-nixos-system-thinknix-18.09.git.696c6be.drv
building '/nix/store/24m1pskvjad9bxin8clba0ijvwmlwylg-issue.drv'...
building '/nix/store/gcbx6dqkbnsc9jkc14yf3mbdswr0rzn3-nixos-version.drv'...
error: while setting up the build environment: getting attributes of path '/etc/hosts': Permission denied

@magnetophon
Copy link
Member Author

Does anyone have an idea what's going on here?
I just tried to upgrade to the latest nixos-unstable, but am still getting this error.

@ryantm
Copy link
Member

ryantm commented Jul 5, 2018

@magnetophon Thank you for trying the latest nixos-unstable. A suggestion I have for you is to try simplifying your configuration until you figure out which part of it is causing the error. You could start by combining all your configuration into one file and then remove half of it and binary search your way to what line is causing the problem.

@magnetophon
Copy link
Member Author

Status update: I've been able to update my system by commenting out certain pkgs:

  • m32edit
  • musnix kernel (which earlier I have been able to build on this system in the period where I was having this problem)

I havent found a link between these pkgs yet.

@ryantm
Copy link
Member

ryantm commented Jul 9, 2018

Are you still getting the same error message?

@magnetophon
Copy link
Member Author

magnetophon commented Jul 9, 2018

@ryantm Yes I am.
I just tried updating a pkg in my local nixpkgs, and got it again when I ran nixos-rebuild.

Also, as a user,I tried:

nix-env -f $NIXPKGS -i clipster
installing 'clipster-2.0.0'
these derivations will be built:
  /nix/store/rcdg9dab82vc1vqzk4qhvr5lx91jwi7x-source.drv
  /nix/store/4n3m6615w9cq9n5dz61ah2fb4l04gjad-clipster-2.0.0.drv
error: while setting up the build environment: getting attributes of path '/etc/hosts': Permission denied

@ryantm
Copy link
Member

ryantm commented Jul 9, 2018

What is the output of ls -la /etc/hosts for your system?

For me, it's:

[ryantm@machine:~/p/nixpkgs]$ ls -la /etc/hosts  
lrwxrwxrwx 1 root root 17 Jun  5 21:44 /etc/hosts -> /etc/static/hosts 

@magnetophon
Copy link
Member Author

@ryantm
I get:

ls -la /etc/hosts
lrwxrwxrwx 1 root root 17  9 jul 18:46 /etc/hosts -> /etc/static/hosts

@magnetophon
Copy link
Member Author

Another odd thing about this:
NixOS will rebuild a rt kernel just fine, but when I put a new version number of it in nixpkgs, I get the above error.

@magnetophon
Copy link
Member Author

magnetophon commented Jul 17, 2018

@ryantm I've simplified my configuration to the maximum, and stil get the same error, as long as I include one of the affected packages.
I'm building with nixos-rebuild test -I nixos-config=/home/me/test.nix -I nixpkgs=$NIXPKGS

This nixpkgs has a new version and hash for ir.lv2.
Without that, it doesn't build either, but that's because of library incompatibilities.

The content of test.nix is:

{pkgs, config, ...}: with pkgs;
{
  fileSystems =
  {
    "/" =
    {
      device = "/dev/mapper/VolGroup-nixos";
      fsType = "ext4";
      options = [ "relatime" "errors=remount-ro" "discard" ];
    };
    "/home" =
    { device = "/dev/mapper/VolGroup-home";
      fsType = "ext4";
      options = [ "relatime" "errors=remount-ro" "discard" ];
    };
  };

  swapDevices = [{
    device = "/dev/mapper/VolGroup-swap";
  }];

  boot.loader.systemd-boot.enable = true;

  environment.systemPackages = [    ir.lv2 ];
}

The output is:

nixos-rebuild test -I nixos-config=/home/bart/test.nix -I nixpkgs=$NIXPKGS                                                                                                               [21:25:54]
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
building Nix...
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
building the system configuration...
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
trace: warning: You don't have `system.nixos.stateVersion` explicitly set. Expect things to break.
these derivations will be built:
  /nix/store/nsalgsff163hzh63nqd6h9q916w06x0g-source.drv
  /nix/store/3n7hzab254q4mq65ly9593mj68v4aqj8-ir.lv2-1.2.4.drv
  /nix/store/ahhcn3scpzwwvs6ddfd64hwxir4ibfa3-system-path.drv
  /nix/store/2pidp87ir57gvhq3hl7qgrswwpa1c6nl-dbus-1.drv
  /nix/store/9fjg194j29lkfnxdwispy3c30ii3jsl3-hwdb.bin.drv
  /nix/store/1klbk9dj3i9s97by9alfxhyg3kf2r950-unit-script.drv
  /nix/store/1r4xjanizabchqzkb8dnb2p9mfj2bdkw-unit-post-resume.service.drv
  /nix/store/5hdw4znjv9nh7pppsrzndl4y04rhk564-unit-polkit.service.drv
  /nix/store/6i1bhbv7n8xy1mb9z5n58ij1868ny37r-unit-systemd-fsck-.service.drv
  /nix/store/lzviz5pkyfb3msnk5f2lncd17c5b3s88-unit-dbus.service.drv
  /nix/store/kfplkadmas91fvdwwiywya786bv3fvmm-unit-script.drv
  /nix/store/qhdghd2689r31jw0zfyss5ylj2vwr4n6-unit-pre-sleep.service.drv
  /nix/store/zdh0cc75n3xrapjjq0iqnqjmhkgajka2-firewall-stop.drv
  /nix/store/1w7j7gh0n9gz68plskjq9sdhml1pj2lq-firewall-reload.drv
  /nix/store/zsy80j1zsf77fz9fmldai4dn00hywida-unit-firewall.service.drv
  /nix/store/lpskpfrrsw2dmjfvzibxh9ilrff00mv0-system-units.drv
  /nix/store/46f6sgdck8j0498qnblyg2h4iiq6pig8-unit-dbus.service.drv
  /nix/store/wmqmzspnp4lhx1b8cmfp5khim56h4dqd-user-units.drv
  /nix/store/3jp4w9dnnir6fpyxl4d2fcay80gd7gsj-etc.drv
  /nix/store/623aa959y1kvnfhbsz69byhps8v8h221-stage-1-init.sh.drv
  /nix/store/530yqs4gmxcmigm2gbby6rsgpzam2bym-initrd.drv
  /nix/store/0byxkzclx6a6h44a9vkwkv4jkc68c1dh-nixos-system-nixos-18.09.git.dae9cf6.drv
building '/nix/store/9fjg194j29lkfnxdwispy3c30ii3jsl3-hwdb.bin.drv'...
building '/nix/store/zdh0cc75n3xrapjjq0iqnqjmhkgajka2-firewall-stop.drv'...
building '/nix/store/1klbk9dj3i9s97by9alfxhyg3kf2r950-unit-script.drv'...
building '/nix/store/kfplkadmas91fvdwwiywya786bv3fvmm-unit-script.drv'...
Adding hwdb files for package /nix/store/mhjpsx24jwm660rkcf43yrm2kww8q8y9-systemd-238
error: while setting up the build environment: getting attributes of path '/etc/hosts': Permission denied

I also get the error if I change

environment.systemPackages = [    ir.lv2 ];

into:

  environment.systemPackages = [    m32edit ];
  nixpkgs.config.allowUnfree = true;

and build without -I nixpkgs=$NIXPKGS.

How can I continue troubleshooting?

@ryantm
Copy link
Member

ryantm commented Jul 18, 2018

@magnetophon How about we try using the --show-trace option with nixos-rebuild?

@magnetophon
Copy link
Member Author

@ryantm Thanks, but unfortunately that doesn't tell us much:

nixos-rebuild test --show-trace -I nixos-config=/home/bart/test.nix -I nixpkgs=$NIXPKGS                                                                                                  
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
building Nix...
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
building the system configuration...
warning: Nix search path entry '$HOME/.nix-defexpr/channels' does not exist, ignoring
trace: warning: You don't have `system.nixos.stateVersion` explicitly set. Expect things to break.
these derivations will be built:
  /nix/store/nsalgsff163hzh63nqd6h9q916w06x0g-source.drv
  /nix/store/3n7hzab254q4mq65ly9593mj68v4aqj8-ir.lv2-1.2.4.drv
  /nix/store/ahhcn3scpzwwvs6ddfd64hwxir4ibfa3-system-path.drv
  /nix/store/2pidp87ir57gvhq3hl7qgrswwpa1c6nl-dbus-1.drv
  /nix/store/5hdw4znjv9nh7pppsrzndl4y04rhk564-unit-polkit.service.drv
  /nix/store/6i1bhbv7n8xy1mb9z5n58ij1868ny37r-unit-systemd-fsck-.service.drv
  /nix/store/lzviz5pkyfb3msnk5f2lncd17c5b3s88-unit-dbus.service.drv
  /nix/store/lpskpfrrsw2dmjfvzibxh9ilrff00mv0-system-units.drv
  /nix/store/46f6sgdck8j0498qnblyg2h4iiq6pig8-unit-dbus.service.drv
  /nix/store/wmqmzspnp4lhx1b8cmfp5khim56h4dqd-user-units.drv
  /nix/store/3jp4w9dnnir6fpyxl4d2fcay80gd7gsj-etc.drv
  /nix/store/0byxkzclx6a6h44a9vkwkv4jkc68c1dh-nixos-system-nixos-18.09.git.dae9cf6.drv
error: while setting up the build environment: getting attributes of path '/etc/hosts': Permission denied

@ryantm
Copy link
Member

ryantm commented Jul 19, 2018

Sorry, I don't have any other ideas. I see you don't have the stateVersion set, but I'm not sure how that would be relevant. Maybe try posting on the forum. Or asking on IRC.

@ryantm
Copy link
Member

ryantm commented Jul 19, 2018

You could try installing your configuration on another machine or virtual machine and see if there is some state-based issue.

@magnetophon
Copy link
Member Author

@ryantm Thanks.

Now we know it isn't config-related, It would have to be a state-based issue, wouldn't it?
I don't have a VM set up right now, and I'm online via sketchy mobile data, so no easy way to test.

If it is a state-based issue, would I have to reinstall my machine, or is there another way?

@magnetophon
Copy link
Member Author

@ryantm I had some HW issues in the meantime, but now I'm back in buisiness, and on a decent net pipe.

The debugging continues.

@magnetophon
Copy link
Member Author

Currently I'm running nix-store --verify --check-contents --repair, and it's finding and repairing lots of modified paths.
I think my old ssd was broken, and hope that after this repair, my NixOS will be healthy again...

@magnetophon
Copy link
Member Author

That didn't fix it, unfortunately.

@magnetophon
Copy link
Member Author

Turns out that my issue was this line, which links /etc/hosts to a file in my user home dir.
Thanks to @LnL7 for providing the fix on IRC!

@chrissound
Copy link

chrissound commented Dec 18, 2019

I got this same error when I by accident added my ssh private key to the sandbox (file permission 600)...

I'd assume this should be a bug then? As the only way to recover that I know of is, booting into a previous generation.

Setting the file permission to 777 temporarily, still results in the same error.

@jonringer
Copy link
Contributor

Ran into this error when running nixos-install on a new SSD from an already established nixos install. The issue was that I was using su , using sudo -i seems to not cause issues.

More context: nix daemon was refrencing paths from /run/user/$UID which was the cause of the issue.

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