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

  • Done
  • quality assurance status badge
Details
4 participants
  • Andrew Tropin
  • Jan Nieuwenhuizen
  • Ludovic Courtès
  • Xinglu Chen
Owner
unassigned
Submitted by
Jan Nieuwenhuizen
Severity
normal
J
J
Jan Nieuwenhuizen wrote on 1 Oct 2021 17:46
(address . bug-guix@gnu.org)
87y27czr0v.fsf@gnu.org
Hi,

When using su or sudo to enter an account managed by guix home, I get
this error

Toggle snippet (11 lines)
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"

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


$ ssh guix@localhost -p 2222
guix@localhost's password:
Last login: Tue Jun 23 11:45:08 2020 from 2001:980:1b4f:1:216:d3ff:fe29:7cdb
guix@dundal ~$ guix home reconfigure home-minimal.scm
/gnu/store/fgxpmf1iwjp9f8dfyaf7wxqa8105lq3w-home
Cleaning up symlinks from previous home-environment.

Skipping /home/guix/.config/fontconfig (not an empty directory)... done
Skipping /home/guix/.config (not an empty directory)... done
Cleanup finished.

New symlinks to home-environment will be created soon.
All conflicting files will go to /home/guix/1633101995-guix-home-legacy-configs-backup.

Skipping /home/guix/.config (directory already exists)... done
Creating /home/guix/.config/fontconfig... done
Symlinking /home/guix/.config/fontconfig/fonts.conf -> /gnu/store/phj2z2iiqdhryfy7mqral0b9qz3hlva6-fonts.conf... done
Symlinking /home/guix/.config/test.conf -> /gnu/store/bdixb09v30bvhpgi2f6ndiq25wzb9l74-tmp-file.txt... done
Symlinking /home/guix/.bash_profile -> /gnu/store/j3vhlswj46psxicapnq8c9p1jrwd55rk-bash_profile... done
Symlinking /home/guix/.profile -> /gnu/store/fxbppk3pqzdi3zzy0xl5vg1ir6c5jzq5-shell-profile... done
Symlinking /home/guix/.bashrc -> /gnu/store/513j2xkszmcmv7fiawh59mr0i1fmin55-bashrc... done
done
Finished updating symlinks.

Comparing /gnu/store/fgxpmf1iwjp9f8dfyaf7wxqa8105lq3w-home/profile/share/fonts and
/gnu/store/fgxpmf1iwjp9f8dfyaf7wxqa8105lq3w-home/profile/share/fonts... done (same)
Evaling on-change gexps.

On-change gexps evaluation finished.

guix@dundal ~$ guix home list-generations
]8;;file://dundal/var/guix/profiles/per-user/guix/guix-home-1-link\Generation 1 Oct 01 2021 12:19:16]8;;\ (current)
file name: /var/guix/profiles/per-user/guix/guix-home-1-link
canonical file name: /gnu/store/fgxpmf1iwjp9f8dfyaf7wxqa8105lq3w-home
channels:
guix:
branch: master
configuration file: ]8;;file://dundal/gnu/store/kjha5z8mck0pa9jrgx2266rq1lvlb3ji-configuration.scm\/gnu/store/kjha5z8mck0pa9jrgx2266rq1lvlb3ji-configuration.scm]8;;\
guix@dundal ~$ logout
Connection to localhost closed.
17:26:49 janneke@dundal:~
$ sudo -i -u guix
Password:
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"
guix@dundal ~$ ls -ltrF /run/user
total 0
drwx------ 7 gdm gdm 160 Oct 1 12:16 971/
drwx------ 13 janneke janneke 260 Oct 1 13:07 1000/
guix@dundal ~$ logout
17:29:34 janneke@dundal:~
$ su - guix
Password:
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"
17:37:33 janneke@dundal:~
$ ssh guix@localhost -p 2222
guix@localhost's password:
Last login: Fri Oct 1 17:23:35 2021 from 127.0.0.1
guix@dundal ~$
Attachment: home-minimal.scm
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com| Avatar® http://AvatarAcademy.com
X
X
Xinglu Chen wrote on 1 Oct 2021 19:05
(name . Andrew Tropin)(address . andrew@trop.in)
87ilygllp7.fsf@yoctocell.xyz
On Fri, Oct 01 2021, Jan Nieuwenhuizen wrote:

Toggle quote (24 lines)
> 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.
-----BEGIN PGP SIGNATURE-----

iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmFXP+QVHHB1YmxpY0B5
b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5becQAL7ZlFkF0dSuO3SIN6Npvb6cSrNj
yjELwonVnqSuFYfiQcSt7C/7iEtH+clWjVac7HxGwxIspl6c+dkPKAcgcTJyyfCn
P4rrUtVmwxchQh/MjRCLZp6y+v9CMQLA/91fzi1VlOrsxYYttz05Yn2h7k36TAsX
sLgWGUvK16ohanoja+1oOh7PPCrYy8ufarK3TnBOrGu3lUIBIm6v+bnr3gLicjIk
ODJJ/VZyN2g64SQgbVMtyzZHLX3xCwQGD88ZZCmyqT3938408cpybUJelXx5RjuV
WVyG1hsMEwT2IMaJBosP/ZLjxlRIeQGF/eYFXoadkgfF9DJJcHGj7N671IkBCkY6
I4RkXybPDx2JqWGbA4NmPjovrX2yALF0EaF0YGNOpvqPanVvdtJpHL1WxZHV+9jW
/gGBt/H1rnEYxi2h42oke6rsGpiexouro5TAbzrjincD62U2lc3MADuoyGHErsnN
6gQDVK4kdOwiH5VTw8jgVaH26wgnekF2ySKR90nraiImUhvu9a4iuV/jrDObZjzv
ZllX2T5Dz1+mRVi2o2rUY9pqmZsnsG6vc9R1YzxTimv7KDfqeCi3SB7GxzF6bexE
iQJe08X9UwBrFWSnTsSUsJ2lzYQgFyRBmOXo7Q7zO6TElq4Q7bOEwYlBuNJgUGnq
oOt/vw45UPc0x+R5
=hnkm
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 7 Oct 2021 07:21
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
871r4xwgtn.fsf@trop.in
On 2021-10-01 17:46, Jan Nieuwenhuizen wrote:

Toggle quote (102 lines)
> 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
>
>
> $ ssh guix@localhost -p 2222
> guix@localhost's password:
> Last login: Tue Jun 23 11:45:08 2020 from 2001:980:1b4f:1:216:d3ff:fe29:7cdb
> guix@dundal ~$ guix home reconfigure home-minimal.scm
> /gnu/store/fgxpmf1iwjp9f8dfyaf7wxqa8105lq3w-home
> Cleaning up symlinks from previous home-environment.
>
> Skipping /home/guix/.config/fontconfig (not an empty directory)... done
> Skipping /home/guix/.config (not an empty directory)... done
> Cleanup finished.
>
> New symlinks to home-environment will be created soon.
> All conflicting files will go to /home/guix/1633101995-guix-home-legacy-configs-backup.
>
> Skipping /home/guix/.config (directory already exists)... done
> Creating /home/guix/.config/fontconfig... done
> Symlinking /home/guix/.config/fontconfig/fonts.conf -> /gnu/store/phj2z2iiqdhryfy7mqral0b9qz3hlva6-fonts.conf... done
> Symlinking /home/guix/.config/test.conf -> /gnu/store/bdixb09v30bvhpgi2f6ndiq25wzb9l74-tmp-file.txt... done
> Symlinking /home/guix/.bash_profile -> /gnu/store/j3vhlswj46psxicapnq8c9p1jrwd55rk-bash_profile... done
> Symlinking /home/guix/.profile -> /gnu/store/fxbppk3pqzdi3zzy0xl5vg1ir6c5jzq5-shell-profile... done
> Symlinking /home/guix/.bashrc -> /gnu/store/513j2xkszmcmv7fiawh59mr0i1fmin55-bashrc... done
> done
> Finished updating symlinks.
>
> Comparing /gnu/store/fgxpmf1iwjp9f8dfyaf7wxqa8105lq3w-home/profile/share/fonts and
> /gnu/store/fgxpmf1iwjp9f8dfyaf7wxqa8105lq3w-home/profile/share/fonts... done (same)
> Evaling on-change gexps.
>
> On-change gexps evaluation finished.
>
> guix@dundal ~$ guix home list-generations
> ]8;;file://dundal/var/guix/profiles/per-user/guix/guix-home-1-link\Generation 1 Oct 01 2021 12:19:16]8;;\ (current)
> file name: /var/guix/profiles/per-user/guix/guix-home-1-link
> canonical file name: /gnu/store/fgxpmf1iwjp9f8dfyaf7wxqa8105lq3w-home
> channels:
> guix:
> repository URL: https://git.savannah.gnu.org/git/guix.git
> branch: master
> commit: ]8;;https://git.savannah.gnu.org/cgit/guix.git/commit/?id=56b10709efc4eb35df66f52a20ce3cb7fab4fee6\56b10709efc4eb35df66f52a20ce3cb7fab4fee6]8;;\
> configuration file: ]8;;file://dundal/gnu/store/kjha5z8mck0pa9jrgx2266rq1lvlb3ji-configuration.scm\/gnu/store/kjha5z8mck0pa9jrgx2266rq1lvlb3ji-configuration.scm]8;;\
> guix@dundal ~$ logout
> Connection to localhost closed.
> 17:26:49 janneke@dundal:~
> $ sudo -i -u guix
> Password:
> 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"
> guix@dundal ~$ ls -ltrF /run/user
> total 0
> drwx------ 7 gdm gdm 160 Oct 1 12:16 971/
> drwx------ 13 janneke janneke 260 Oct 1 13:07 1000/
> guix@dundal ~$ logout
> 17:29:34 janneke@dundal:~
> $ su - guix
> Password:
> 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"
> 17:37:33 janneke@dundal:~
> $ ssh guix@localhost -p 2222
> guix@localhost's password:
> Last login: Fri Oct 1 17:23:35 2021 from 127.0.0.1
> guix@dundal ~$

Thank you for a very detailed report.

pam_elogind doesn't create a session, when the login shell spawned by
sudo or su => XDG_RUNTIME_DIR not get created => this message appears.

I think we can omit execution of any processes by on-first-login script
in case session wasn't created. Added the check:
From aab6df0298963fe91a6ebfd1dadbc1530eceeff7 Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew@trop.in>
Date: Thu, 7 Oct 2021 08:12:04 +0300
Subject: [PATCH] home-services: on-first-login: Check if XDG_RUNTIME_DIR
exists.

* gnu/home-services.scm (on-first-login): on-first-login won't execute
anything if XDG_RUNTIME_DIR doesn't exists.
---
gnu/home-services.scm | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

Toggle diff (20 lines)
diff --git a/gnu/home-services.scm b/gnu/home-services.scm
index 9f1e986616..0b77a1321d 100644
--- a/gnu/home-services.scm
+++ b/gnu/home-services.scm
@@ -286,8 +286,11 @@ will be put in @file{~/.guix-home/files}.")))
;; XDG_RUNTIME_DIR dissapears on logout, that means such trick
;; allows to launch on-first-login script on first login only
;; after complete logout/reboot.
- (when (not (file-exists? flag-file-path))
- (begin #$@gexps (touch flag-file-path))))))
+ (if (file-exists? xdg-runtime-dir)
+ (when (not (file-exists? flag-file-path))
+ (begin #$@gexps (touch flag-file-path)))
+ (display "XDG_RUNTIME_DIR doesn't exists, the session wasn't
+created, on-first-login script won't execute anything.")))))
(define (on-first-login-script-entry m-on-first-login)
"Return, as a monadic value, an entry for the on-first-login script
--
2.33.0
--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmFeg9QACgkQIgjSCVjB
3rA7AxAAj/q+C7jdnSnrWrEhjcrs8MXy/hXg5lmztAppf7K0WWYBCwJLvxtXPRGL
6JzwpVseM4FSa3pboDheKKqGfe0SjH22w26qQzABzuNhdTZ76Xr+sQwXcaIAN2f5
8+zBTAOGwVJJBUJSShp8/Ab0dJyeaZQqVpj07GwvFbtKvf70usthKrRB0W2Q0Y4S
HQMdd+T8NYKQMDrJY+FcBM3V75RXr0o0AD/ypUDLr8+fcS1KnlvcV/o5PNJLwFO5
U2WphVsNBuy5jFAk7ZrabcXmZPDCyABYDSFHkB47xFq2uYgl7ymVoztCleCCbtPa
VWB//OWL1JBjbxXsR09U2ay//S3+gvh+GaTSic2RI81jl07IJmAX5LlQRLA5HUiy
bEwhxGiu4HXc5rvFO0cysSbnUTauxQVtpOL7jHjI123aaVAsnu8Pvn/tFzbNGn4i
obYpHF6D5KNkBayxt2Ku022fOYVdZwul4/ZXxnDD6wWZxFmIHOtptACcGDcsqKPF
lY9dAPsAHI10KSpaALI5AwuHZPtcQ4/KyHv/fAtQh2PhAfYyckRepNw4iUwoA3oq
hmNdU3dJ9oFa4tCVZcSjvQhHlTdTRijgY51ZNslv1iLlPoi5bg7UZW9254BZHSCn
yjUNuXG0YjeFww4QStv3XBVz/M5BDRw9/JMksaDMq6QsPKDAI94=
=PzFK
-----END PGP SIGNATURE-----

X
X
Xinglu Chen wrote on 5 Nov 2021 17:58
87ee7u4k0a.fsf@disroot.org
Hi,

On Thu, Oct 07 2021, Andrew Tropin wrote:

Toggle quote (54 lines)
> On 2021-10-01 17:46, 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---
>>
>> [...]
>
> Thank you for a very detailed report.
>
> pam_elogind doesn't create a session, when the login shell spawned by
> sudo or su => XDG_RUNTIME_DIR not get created => this message appears.
>
> I think we can omit execution of any processes by on-first-login script
> in case session wasn't created. Added the check:
>
> From aab6df0298963fe91a6ebfd1dadbc1530eceeff7 Mon Sep 17 00:00:00 2001
> From: Andrew Tropin <andrew@trop.in>
> Date: Thu, 7 Oct 2021 08:12:04 +0300
> Subject: [PATCH] home-services: on-first-login: Check if XDG_RUNTIME_DIR
> exists.
>
> * gnu/home-services.scm (on-first-login): on-first-login won't execute
> anything if XDG_RUNTIME_DIR doesn't exists.
> ---
> gnu/home-services.scm | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/gnu/home-services.scm b/gnu/home-services.scm
> index 9f1e986616..0b77a1321d 100644
> --- a/gnu/home-services.scm
> +++ b/gnu/home-services.scm
> @@ -286,8 +286,11 @@ will be put in @file{~/.guix-home/files}.")))
> ;; XDG_RUNTIME_DIR dissapears on logout, that means such trick
> ;; allows to launch on-first-login script on first login only
> ;; after complete logout/reboot.
> - (when (not (file-exists? flag-file-path))
> - (begin #$@gexps (touch flag-file-path))))))
> + (if (file-exists? xdg-runtime-dir)
> + (when (not (file-exists? flag-file-path))

Use (unless …) instead of (when (not …)…).

Toggle quote (4 lines)
> + (begin #$@gexps (touch flag-file-path)))
> + (display "XDG_RUNTIME_DIR doesn't exists, the session wasn't
> +created, on-first-login script won't execute anything.")))))

It would be good to tell the user how they could manually run the
script, that way they could manually set/create $XDG_RUNTIME_DIR and run
the script.

"XDG_RUNTIME_DIR doesn't exist; the 'on-first-login' script won't
execute anything. You can manually execute the script by running
'$HOME/.guix-home/on-first-login'

WDYT?
-----BEGIN PGP SIGNATURE-----

iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmGFYrUVHHB1YmxpY0B5
b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5UuAP/RI/AZBKmH088uB629hRt5X+y69x
JENCOTUBYP9VPzPx0uKA7COYRCc7Ac4d1OozDnXyp56kd3fTi+YnDbhjjrIo5MQo
RmzaoGvGwAGy142mFt6lJ2H/7S/2GirK7v1O6eOLZfV96AEruVeJpkMjmQ9X3X8g
paTcJz5Vid88ket5k7hbL4S/ZZh3hqkEJCYWX3Dt5myHc3gJvEalfbApvEA9qBLC
hLt7627shDD3krafMEI+/Ytj/00fSExBnwPEwOsCcUpzGZQOea5reW3FHdBdEcqs
NML+MG8sxcil8K0lZMBvWnUbow+HOaglu4HpmgwJ1SuO5DY1rJg888V6znq64+83
BWDsgh7JzT3TbKVji77Nx6CyMRgOrBG0AYI1mNB2TNMcUTifocRJK8geGT3jnYM2
DSCHVjGIlNhdwwYo0Toe8D9tz/EnAHYgjhIqmHgNKpv3XKpbPi0zcu3T1t0l9r6Y
Sl2xWV5i7rxYzh2ycmWsTMBnVoyoCzLjuzw/4eNSNx7ZzUAendpIzx7vK2ii9GVr
w7XxinI841/bsD1/r+jZ/PHrZd3JoLVErWiY9bQiHXW9M1dubvIyZ5nXziOCw6Cr
KsIDUSdQdsU0rNDhECkPDJUAaSUao+lfxSCQJI5g2nBxHnLvXu/h0zJg1Rne4Tgx
IHYXA1PEdY2gYgns
=UnP9
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 8 Nov 2021 10:24
87o86vgfu4.fsf@trop.in
On 2021-11-05 17:58, Xinglu Chen wrote:

Toggle quote (74 lines)
> Hi,
>
> On Thu, Oct 07 2021, Andrew Tropin wrote:
>
>> On 2021-10-01 17:46, 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---
>>>
>>> [...]
>>
>> Thank you for a very detailed report.
>>
>> pam_elogind doesn't create a session, when the login shell spawned by
>> sudo or su => XDG_RUNTIME_DIR not get created => this message appears.
>>
>> I think we can omit execution of any processes by on-first-login script
>> in case session wasn't created. Added the check:
>>
>> From aab6df0298963fe91a6ebfd1dadbc1530eceeff7 Mon Sep 17 00:00:00 2001
>> From: Andrew Tropin <andrew@trop.in>
>> Date: Thu, 7 Oct 2021 08:12:04 +0300
>> Subject: [PATCH] home-services: on-first-login: Check if XDG_RUNTIME_DIR
>> exists.
>>
>> * gnu/home-services.scm (on-first-login): on-first-login won't execute
>> anything if XDG_RUNTIME_DIR doesn't exists.
>> ---
>> gnu/home-services.scm | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/gnu/home-services.scm b/gnu/home-services.scm
>> index 9f1e986616..0b77a1321d 100644
>> --- a/gnu/home-services.scm
>> +++ b/gnu/home-services.scm
>> @@ -286,8 +286,11 @@ will be put in @file{~/.guix-home/files}.")))
>> ;; XDG_RUNTIME_DIR dissapears on logout, that means such trick
>> ;; allows to launch on-first-login script on first login only
>> ;; after complete logout/reboot.
>> - (when (not (file-exists? flag-file-path))
>> - (begin #$@gexps (touch flag-file-path))))))
>> + (if (file-exists? xdg-runtime-dir)
>> + (when (not (file-exists? flag-file-path))
>
> Use (unless …) instead of (when (not …)…).
>
>> + (begin #$@gexps (touch flag-file-path)))
>> + (display "XDG_RUNTIME_DIR doesn't exists, the session wasn't
>> +created, on-first-login script won't execute anything.")))))
>
> It would be good to tell the user how they could manually run the
> script, that way they could manually set/create $XDG_RUNTIME_DIR and run
> the script.
>
> "XDG_RUNTIME_DIR doesn't exist; the 'on-first-login' script won't
> execute anything. You can manually execute the script by running
> '$HOME/.guix-home/on-first-login'
>
> WDYT?

Addressed suggestions, attaching updated patch.
From 8b924b02ab917632047d6653f19d9b16175989bf Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew@trop.in>
Date: Thu, 7 Oct 2021 08:12:04 +0300
Subject: [PATCH] home-services: on-first-login: Check if XDG_RUNTIME_DIR
exists.

* gnu/home-services.scm (on-first-login): on-first-login won't execute
anything if XDG_RUNTIME_DIR doesn't exists.
---
gnu/home/services.scm | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

Toggle diff (22 lines)
diff --git a/gnu/home/services.scm b/gnu/home/services.scm
index 5c9b743f7b..1e295b6afe 100644
--- a/gnu/home/services.scm
+++ b/gnu/home/services.scm
@@ -286,8 +286,13 @@ (define (compute-on-first-login-script _ gexps)
;; XDG_RUNTIME_DIR dissapears on logout, that means such trick
;; allows to launch on-first-login script on first login only
;; after complete logout/reboot.
- (when (not (file-exists? flag-file-path))
- (begin #$@gexps (touch flag-file-path))))))
+ (if (file-exists? xdg-runtime-dir)
+ (unless (file-exists? flag-file-path)
+ (begin #$@gexps (touch flag-file-path)))
+ (display "XDG_RUNTIME_DIR doesn't exists, on-first-login script
+won't execute anything. You can check if xdg runtime directory exists,
+XDG_RUNTIME_DIR variable is set to apropriate value and manually execute the
+script by running '$HOME/.guix-home/on-first-login'")))))
(define (on-first-login-script-entry m-on-first-login)
"Return, as a monadic value, an entry for the on-first-login script
--
2.33.0
Also, added a note about elogind/XDG_RUNTIME_DIR to manual.
From f5d35fd4f542a11226c0159ee32498e374ff40a2 Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew@trop.in>
Date: Mon, 8 Nov 2021 12:22:04 +0300
Subject: [PATCH] doc: Add a note about elogind and XDG_RUNTIME_DIR for Guix
Home.

* doc/guix.texi (Declaring the Home Environment): Add a note about elogind and
XDG_RUNTIME_DIR.
---
doc/guix.texi | 7 +++++++
1 file changed, 7 insertions(+)

Toggle diff (20 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 3355a535ad..36437cf161 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -35916,6 +35916,13 @@ guix home reconfigure config.scm
This ``builds'' your home environment and creates @file{~/.guix-home}
pointing to it. Voilà!
+@quotation
+Ensure that operating system has elogind or any other mechanism, which
+creates xdg runtime directory and sets @env{XDG_RUNTIME_DIR} variable.
+Otherwise, @file{on-first-login} script won't execute anything, and
+process like userland Shepherd and its descendants won't start.
+@end quotation
+
@node Configuring the Shell
@section Configuring the Shell
This section is safe to skip if your shell or shells are managed by
--
2.33.0
Oleg, please apply it if it looks good.

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmGI7NMACgkQIgjSCVjB
3rAbfw/+LytNQu+aIiMgrUK3tiCecllYPTaTiuT5wJJGaSBdoePgy3q3EYFCINt0
ViyKK+/+3rhMSmr19cbPhCax9i+aWGUpO9eIlHPLqwgawDljB3wWEKvMHb6EOIMB
YCVfQLXFCAyEmj8F8wjyPCaJUtabctMrNdI/fo3OKyIyPPJmsaAgs/HbCx9pJ2Bp
VzbkXyOzC5QyPdZOb/zZN1PxQ3LtHp7VoNciyPqIFIYq3EVIT7gJMyBxyK/JLaMq
BH9VaATHpz+60fn28EqSz/5DeiQjv0U3M3ocvWKZAV2W3zj+xnc/Aer8RZs3U5yB
Zy2VIlacIdN2ozgrwWRpe5WVtWRDnxH+wiP2jgFF5G8JyDVjLvJEvKhZLLGCkn1r
cBzfI4ns46+0fvyWr0c7HstRZc1NIV4m/yOr2/REuF7bilPqGHh6NiEPtruqQhdc
7vgvJ8Yu/40OHlpYU9oheTw91SJqBn5XQ2XglL87u0UzFJK0SZD0jpn8XcphvWcA
bICKDeDtAfCAQLfqWlIagaFg/WkLe6GGau+cAOEWTgHXPwEYpexe1RNFRcTuzLRd
tXm/7KFVmAPdlSfhl8f8EqoyNInHEp/1WlAUYdbQKt2zmNo9YCgWV+7a4PUOtqQ9
ENWR1Ya1egVgKyknOLsC2JqLvvrtkTSivqXH0+db7emL67TGp0Y=
=0e5H
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 14 Nov 2021 23:11
(name . Andrew Tropin)(address . andrew@trop.in)
87sfvy8k1u.fsf@gnu.org
Hi Andrew and all,

Andrew Tropin <andrew@trop.in> skribis:

Toggle quote (10 lines)
> On 2021-11-05 17:58, Xinglu Chen wrote:
> From 8b924b02ab917632047d6653f19d9b16175989bf Mon Sep 17 00:00:00 2001
> From: Andrew Tropin <andrew@trop.in>
> Date: Thu, 7 Oct 2021 08:12:04 +0300
> Subject: [PATCH] home-services: on-first-login: Check if XDG_RUNTIME_DIR
> exists.
>
> * gnu/home-services.scm (on-first-login): on-first-login won't execute
> anything if XDG_RUNTIME_DIR doesn't exists.

Applied, with a “Fixes” line in the commit log. However…

Toggle quote (15 lines)
> +++ b/gnu/home/services.scm
> @@ -286,8 +286,13 @@ (define (compute-on-first-login-script _ gexps)
> ;; XDG_RUNTIME_DIR dissapears on logout, that means such trick
> ;; allows to launch on-first-login script on first login only
> ;; after complete logout/reboot.
> - (when (not (file-exists? flag-file-path))
> - (begin #$@gexps (touch flag-file-path))))))
> + (if (file-exists? xdg-runtime-dir)
> + (unless (file-exists? flag-file-path)
> + (begin #$@gexps (touch flag-file-path)))
> + (display "XDG_RUNTIME_DIR doesn't exists, on-first-login script
> +won't execute anything. You can check if xdg runtime directory exists,
> +XDG_RUNTIME_DIR variable is set to apropriate value and manually execute the
> +script by running '$HOME/.guix-home/on-first-login'")))))

This pattern is problematic because this text is not internationalized
(not subject to translation). Part of caring about users in Guix
implies ensuring that all messages are internationalized.

The fact that the text is embedded in a generated script makes it a
little trickier. In the installer, we address that by using the message
catalog of the ‘guix’ package like so:

#~(begin
(bindtextdomain "guix" (string-append #$guix "/share/locale"))
(textdomain "guix")
(setlocale LC_ALL ""))

The downside is that the script ends up depending on the ‘guix’ package;
we could optimize that later on.

At any rate, for these cases where you cannot avoid having messages
printed by generated scripts such as this one, the solution would be to:

1. Add calls to ‘bindtextdomain’ and ‘textdomain’ as above
(‘setlocale’ no longer needs to be called explicitly).

2. Import (guix i18n) and wrap messages in ‘G_’ (or ‘N_’) calls.

3. Ensure that each file that uses ‘G_’ or ‘N_’ is listed in
po/guix/POTFILES.in.

Could one of you take a look? :-)

Toggle quote (11 lines)
> Also, added a note about elogind/XDG_RUNTIME_DIR to manual.
>
> From f5d35fd4f542a11226c0159ee32498e374ff40a2 Mon Sep 17 00:00:00 2001
> From: Andrew Tropin <andrew@trop.in>
> Date: Mon, 8 Nov 2021 12:22:04 +0300
> Subject: [PATCH] doc: Add a note about elogind and XDG_RUNTIME_DIR for Guix
> Home.
>
> * doc/guix.texi (Declaring the Home Environment): Add a note about elogind and
> XDG_RUNTIME_DIR.

I tweaked the wording and applied. Thank you!

Ludo’.
L
L
Ludovic Courtès wrote on 14 Nov 2021 23:12
control message for bug #50945
(address . control@debbugs.gnu.org)
87r1bi8jzy.fsf@gnu.org
close 50945
quit
?
Your comment

This issue is archived.

To comment on this conversation send an email to 50945@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 50945
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch