Subject: bug#50945: Guix home: No such file or directory: "/run/user/1003/on-first-login-executed"

From: Xinglu Chen <[email-masked]>
Date: Fri, 01 Oct 2021 19:05:40 +0200

On Fri, Oct 01 2021, Jan Nieuwenhuizen wrote:

> Hi,
>
> When using su or sudo to enter an account managed by guix home, I get
> this error
>
> --8<---------------cut here---------------start------------->8---
> Backtrace:
>            2 (primitive-load "/home/guix/.guix-home/on-first-login")
> In ice-9/ports.scm:
>    461:11  1 (call-with-output-file "/run/user/1003/on-first-login-…" …)
> In unknown file:
>            0 (open-file "/run/user/1003/on-first-login-executed" "w" …)
>
> ERROR: In procedure open-file:
> In procedure open-file: No such file or directory: "/run/user/1003/on-first-login-executed"
> --8<---------------cut here---------------end--------------->8---
>
> Upon a console login or ssh login, /var/run/1003 is created and all is fine.
>
> See below for the scenario, home-minimal.scm is attached.
>
> Greetings,
> Janneke

[ Cc Andrew who did most of the work on Guix Home ]

I think this is because Guix Home relies on $XDG_RUNTIME_DIR to be
defined, otherwise it falls-back to /run/user/UID.  But it looks like
/run/user/UID isn’t created when using ‘su’ to login.  I don’t really
know how these things work under the hood; maybe using $XDG_RUNTIME_DIR
isn’t best idea.