GNU bug report logs - #60106
[Shepherd 0.9.3] ‘system*’ replacement cannot be passed environment variables

Previous Next

Package: guix;

Reported by: Ludovic Courtès <ludovic.courtes <at> inria.fr>

Date: Thu, 15 Dec 2022 22:48:02 UTC

Severity: important

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60106 in the body.
You can then email your comments to 60106 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#60106; Package guix. (Thu, 15 Dec 2022 22:48:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludovic.courtes <at> inria.fr>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Thu, 15 Dec 2022 22:48:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludovic.courtes <at> inria.fr>
To: bug-guix <at> gnu.org
Subject: [Shepherd 0.9.3] ‘system*’ replacement
 cannot be passed environment variables
Date: Thu, 15 Dec 2022 23:47:15 +0100
As we found out while debugging <https://issues.guix.gnu.org/60010>, the
Shepherd 0.9.3, with its ‘system*’ replacement (aka. ‘spawn-command’),
makes it very hard to spawn a command with different environment
variables.

The following options don’t work:

  • Changing shepherd’s own environment variables with ‘setenv’ for
    instance: ‘spawn-command’ calls ‘fork+exec-command’, whose default
    #:environment-variables is provided by the
    ‘default-environment-variables’ parameter, which gets its default
    value at when shepherd starts.  There’s no environment variable
    inheritance, contrary to the real ‘system*’.

  • Parameterizing ‘default-environment-variables’:

       (parameterize ((default-environment-variables …))
         (system* …))

    That won’t work because ‘spawn-command’ delegates to the process
    monitoring fiber, which has a different dynamic state and thus
    doesn’t see this change.

  • Even a plain (set! default-environment-variables …) won’t work,
    probably due to inlining within (shepherd services).

I think we’ll have to add a parameter to ‘spawn-command’ to specify
environment variables.

Ludo’.




Information forwarded to bug-guix <at> gnu.org:
bug#60106; Package guix. (Thu, 22 Dec 2022 16:19:01 GMT) Full text and rfc822 format available.

Message #8 received at 60106 <at> debbugs.gnu.org (full text, mbox):

From: Adam Faiz <adam.faiz <at> disroot.org>
To: 60106 <at> debbugs.gnu.org
Cc: ludovic.courtes <at> inria.fr
Subject: [Shepherd 0.9.3] ‘system*’ replacement cannot be passed environment variables
Date: Thu, 22 Dec 2022 16:17:59 +0000
> I think we’ll have to add a parameter to ‘spawn-command’ to specify
> environment variables.
> 
> Ludo’.
If you do this, can you add an #:append? flag which adds environment 
variables to the inherited environment instead of specifying the 
variables declaratively? It can be #f by default.

It would be very useful for me using the shepherd as init on a foreign 
distro, so I don't have to use the `env` command.




Information forwarded to bug-guix <at> gnu.org:
bug#60106; Package guix. (Thu, 22 Dec 2022 16:48:01 GMT) Full text and rfc822 format available.

Message #11 received at 60106 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludovic.courtes <at> inria.fr>
To: Adam Faiz <adam.faiz <at> disroot.org>
Cc: 60106 <at> debbugs.gnu.org
Subject: Re: [Shepherd 0.9.3] ‘system*’ replacement
 cannot be passed environment variables
Date: Thu, 22 Dec 2022 17:47:37 +0100
Adam Faiz <adam.faiz <at> disroot.org> skribis:

>> I think we’ll have to add a parameter to ‘spawn-command’ to specify
>> environment variables.
>> Ludo’.
> If you do this, can you add an #:append? flag which adds environment
> variables to the inherited environment instead of specifying the
> variables declaratively? It can be #f by default.
>
> It would be very useful for me using the shepherd as init on a foreign
> distro, so I don't have to use the `env` command.

You could always write something like:

  #:environment-variables `("EXTRA_VARIABLE=something" ,@(environ))

to append ‘EXTRA_VARIABLE’ to those of the environment.

So I don’t think we need #:append.

Thanks for your feedback,
Ludo’.




Severity set to 'important' from 'normal' Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 17 Jan 2023 15:22:02 GMT) Full text and rfc822 format available.

Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Sat, 04 Mar 2023 22:11:02 GMT) Full text and rfc822 format available.

Notification sent to Ludovic Courtès <ludovic.courtes <at> inria.fr>:
bug acknowledged by developer. (Sat, 04 Mar 2023 22:11:02 GMT) Full text and rfc822 format available.

Message #18 received at 60106-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Ulf Herrman <striness <at> tilde.club>
Cc: 61803 <at> debbugs.gnu.org, 60106-done <at> debbugs.gnu.org
Subject: Re: bug#61803: [PATCH 0/3] [shepherd] improve race-free spawn+wait
Date: Sat, 04 Mar 2023 23:09:49 +0100
Hi Ulf,

Ulf Herrman <striness <at> tilde.club> skribis:

> From 51ee63ace6f3f52eb196c990664cc6b9af3d3683 Mon Sep 17 00:00:00 2001
> From: ulfvonbelow <striness <at> tilde.club>
> Date: Sat, 25 Feb 2023 00:46:27 -0600
> Subject: [PATCH 2/3] service: accept fork+exec-command argument list in
>  monitor.
>
> Sometimes it's necessary to run startup / shutdown programs as a certain user,
> in a certain directory, with certain environment variables, etc.  Shepherd
> currently provides a replacement for system* that won't race against the
> child process auto-reaper, but this lacks the flexibility Shepherd users are
> used to.
>
> * modules/shepherd/service.scm (process-monitor): treat command instead as
>   argument list to fork+exec-command.
>   (spawn-via-monitor): update to new convention.
>   (fork+exec+wait-command): new procedure.

On this one I took a similar approach but chose to extend
‘spawn-command’ instead of introducing a new procedure—see commit
0f3276a9c3dafbef41b0aab88ba5dda1bb78dc99.

Another difference is explicitly listing keyword arguments so that their
default values are taken from the caller’s dynamic state and not from
that of the process monitoring fiber.  This fixes
<https://issues.guix.gnu.org/60106>.

Let me know what you think!

Thanks,
Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 02 Apr 2023 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 25 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.