Nixpkgs: `nixos-rebuild build` fails as user because of fail in tempdir()

Created on 11 Sep 2017  路  10Comments  路  Source: NixOS/nixpkgs

Issue description / Steps to reproduce

When nixos-rebuilding as user on latest unstable, I get

building Nix...                                                     
building the system configuration...                                
Error in tempdir() using /run/user/1000/nix-build.XXXXXX: Parent directory (/run/user/1000) does not exist at /nix/store/cg6yr2rfsv0mkzk8l57znrvv73gsi6ix-nix-1.11.14/lib/perl5/site_perl/5.24.2/x86_64-linux-thread-multi/Nix/Utils.pm line 45.

Using sudo nixos-rebuild build works.

Technical details

  • System: 17.09.git.96457d2 (Hummingbird)
  • Nix version: nix-env (Nix) 1.11.13
  • Nixpkgs version: "18.03pre114421.799435b7ca"
  • Sandboxing enabled: build-use-sandbox = true
stale

All 10 comments

/run/user/1000 should be actually created by systemd-logind.

Do you have a valid login session?

$ loginctl
   SESSION        UID USER             SEAT             TTY
         8       1000 joerg            seat0
1 sessions listed.
$  loginctl 
   SESSION        UID USER             SEAT             TTY             
         2       1000 m                seat0                            

1 sessions listed.

I encountered this issue several times as well. In my case the system is a NixOS VM I only contact over mosh.

There was no login session on the VM:

~~~
$ loginctl
SESSION UID USER SEAT TTY

0 sessions listed.
~~~

I then tried to trigger a session by connecting via ssh. In the original, still open, mosh session:

~~~
$ loginctl
SESSION UID USER SEAT TTY
13 1100 coconnor

1 sessions listed.
~~~

And sure enough: nixos-rebuild works.

Interesting. Why would there be no session?

This is a problem with mosh and systemd-logind. Once mosh has established the mosh connection, it forks itself and exits the ssh session. When the ssh session is exited your logind session goes away, which also removes /run/user/<uid>/.

I searched around on the issue you mentioned. Rather interesting how common this is!

The command loginctl enable-linger $USER will retain the session after ssh disconnect. This means, for my case, the procedure is:

  1. connect via SSH
  2. enable-linger
  3. screen/tmux
  4. detach
  5. connect with mosh

to establish a persistent session.

From what I see, the issue I encountered is not a NixOS issue. As @Mic92 mentions the issue is with mosh.

I forgot about enable-linger. This fixes the issue with mosh. I have no idea what happens in @matthiasbeyer case. I have the following mounts:

console. $ mount | grep run tmpfs on /run type tmpfs (rw,nosuid,nodev,size=4047128k,mode=755) ramfs on /run/keys type ramfs (rw,nosuid,nodev,relatime,mode=750) tmpfs on /run/wrappers type tmpfs (rw,nodev,relatime) tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=1618848k,mode=700,uid=1000,gid=100)

Apparently another way to solve this is setting

alias mosh-server='systemd-run --user --scope mosh-server'

in the server shell. The session is still gone (looking with loginctl) but Nix is working as usual.

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@rnhmjoj work-around should solve this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lverns picture lverns  路  3Comments

sid-kap picture sid-kap  路  3Comments

langston-barrett picture langston-barrett  路  3Comments

ob7 picture ob7  路  3Comments

edolstra picture edolstra  路  3Comments