GNU bug report logs -
#77707
[shepherd] chdir and invoke do not work as intended in services
Previous Next
To reply to this bug, email your comments to 77707 AT debbugs.gnu.org.
There is no need to reopen the bug first.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guix <at> gnu.org
:
bug#77707
; Package
guix
.
(Thu, 10 Apr 2025 14:45:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-guix <at> gnu.org
.
(Thu, 10 Apr 2025 14:45:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi,
It appears that when changing directory and calling a program with
'invoke', the program still has its current working directory set to
'/'.
I'm betting this may be some kind of odd interaction between the
Shepherd service threads and forking a process?
Can we improve that? If it's a limitation of the implementation model,
than I think it's a surprising enough gotcha to warrant documenting it
in Shepherd's manual.
Here's a simple reproducer:
--8<---------------cut here---------------start------------->8---
modified gnu/system/examples/bare-bones.tmpl
@@ -3,8 +3,8 @@
;; for a "bare bones" setup, with no X11 display server.
(use-modules (gnu))
-(use-service-modules networking ssh)
-(use-package-modules screen ssh)
+(use-service-modules networking shepherd ssh)
+(use-package-modules base screen ssh)
(operating-system
(host-name "komputilo")
@@ -47,7 +47,20 @@
;; Add services to the baseline: a DHCP client and an SSH
;; server. You may wish to add an NTP service here.
- (services (append (list (service dhcp-client-service-type)
+ (services (append (list (simple-service
+ 'forked-processes-cwd-wrong
+ shepherd-root-service-type
+ (list
+ (shepherd-service
+ (provision '(bug-77115))
+ (start #~(lambda _
+ (mkdir "/etc/testdir")
+ (chdir "/etc/testdir")
+ (invoke #$(file-append coreutils "/bin/touch")
+ "new-file.txt")
+ #t))
+ (one-shot? #t))))
+ (service dhcp-client-service-type)
(service openssh-service-type
(openssh-configuration
(openssh openssh-sans-x)
--8<---------------cut here---------------end--------------->8---
Then run it from your tree using something like:
--8<---------------cut here---------------start------------->8---
$(./pre-inst-env guix system vm gnu/system/examples/bare-bones.tmpl --no-graphic)
--8<---------------cut here---------------end--------------->8---
You should see upon inspection that:
--8<---------------cut here---------------start------------->8---
root <at> komputilo ~# ls /new-file.txt
/new-file.txt # wrong place
root <at> komputilo ~# ls /etc/testdir/ # empty
--8<---------------cut here---------------end--------------->8---
--
Thanks,
Maxim
Reply sent
to
Ludovic Courtès <ludo <at> chbouib.org>
:
You have taken responsibility.
(Sun, 13 Apr 2025 19:53:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
:
bug acknowledged by developer.
(Sun, 13 Apr 2025 19:53:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 77707-done <at> debbugs.gnu.org (full text, mbox):
Hi,
Maxim Cournoyer <maxim.cournoyer <at> gmail.com> skribis:
> + (start #~(lambda _
> + (mkdir "/etc/testdir")
> + (chdir "/etc/testdir")
> + (invoke #$(file-append coreutils "/bin/touch")
> + "new-file.txt")
[...]
> You should see upon inspection that:
>
> root <at> komputilo ~# ls /new-file.txt
> /new-file.txt # wrong place
> root <at> komputilo ~# ls /etc/testdir/ # empty
That’s because ‘invoke’ uses ‘system*’, which is in fact within the
‘shepherd’ process an alias for ‘spawn-command’.
This is fixed in 8d88024e0898dd7d4581c4e977c9786af734a855, which will be
in 1.0.4.
However generally speaking it’s a good idea to leave the current
directory of the ‘shepherd’ process unchanged as bad things could happen
otherwise (though ‘with-directory-excursion’ from (shepherd support)
should be safe.)
Thanks,
Ludo’.
Information forwarded
to
bug-guix <at> gnu.org
:
bug#77707
; Package
guix
.
(Mon, 14 Apr 2025 00:32:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 77707 <at> debbugs.gnu.org (full text, mbox):
Hi Ludovic,
[...]
> That’s because ‘invoke’ uses ‘system*’, which is in fact within the
> ‘shepherd’ process an alias for ‘spawn-command’.
>
> This is fixed in 8d88024e0898dd7d4581c4e977c9786af734a855, which will be
> in 1.0.4.
That was fast, kudos!
--
Maxim
This bug report was last modified 20 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.