New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specifiers in user units don't use environment.d values #29414
Comments
environment.d only has an effect on the env block passed to services. It has no effect on the service manager itself. And that's unlikely to change. Since the unit file parser is done bythe service manager it hence doesn't care at all what you do in environment.d Hence, this is expected. We could probably make this clearer in the docs, it currently says this:
We probably should make very clear it only "applies" to the service in the sense that the env block is passed down to them and not in any other way. And we should probably make expressly clear it does not apply to the service manager itself. |
On Mon, Oct 30, 2023 at 03:37:06PM -0700, Lennart Poettering wrote:
environment.d only has an effect on the env block passed to services. It has no effect on the service manager itself. And that's unlikely to change. Since the unit file parser is done bythe service manager it hence doesn't care at all what you do in environment.d
Hence, this is expected. We could probably make this clearer in the docs, it currently says this:
That is very unexpected to me -- in particular, I was expecting to be able to
have services grab configuration from under `$XDG_CONFIG_HOME` and write
persistence information under `$XDG_STATE_HOME`.
(In particular, am writing a service for `pizauth` and would like it to write
the output of `pizauth dump` to a state file on shutdown, cf
<https://github.com/ltratt/pizauth#persistence>)
|
but why would set want to set these variables then? |
… service manager's own env block Fixes: systemd#29414
… service manager's own env block Fixes: #29414
On Wed, Nov 01, 2023 at 01:35:36AM -0700, Lennart Poettering wrote:
> That is very unexpected to me -- in particular, I was expecting to be able to have services grab configuration from under `$XDG_CONFIG_HOME` and write persistence information under `$XDG_STATE_HOME`. (In particular, am writing a service for `pizauth` and would like it to write the output of `pizauth dump` to a state file on shutdown, cf <https://github.com/ltratt/pizauth#persistence>)
but why would set want to *set* these variables then?
I believe my reproduction might have been confusing -- it was meant to
illustrate the unexpected situation that the XDG settings set up in
`~/.config/environment.d/` had been picked up by the login shell, but were not
used in evaluating the specifiers for the units.
In particular, I would expect `%C` in a user unit to always evaluate to the
`environment.d` setting of `$XDG_CONFIG_HOME` (indeed, I'm not alone in this
apparent misunderstanding, as [the Arch Linux wiki
page](https://wiki.archlinux.org/title/Systemd/User#Environment_variables) on
this also lists `environment.d` as being able to set the user unit's env block)
|
Reading through #29801 and noting that using |
… service manager's own env block Fixes: systemd#29414
… service manager's own env block Fixes: systemd#29414 (cherry picked from commit bebf6fc)
… service manager's own env block Fixes: systemd#29414 (cherry picked from commit bebf6fc) (cherry picked from commit bb0a377) (cherry picked from commit 1d6c94b)
… service manager's own env block Fixes: systemd#29414 (cherry picked from commit bebf6fc) (cherry picked from commit bb0a377)
systemd version the issue has been seen with
254.5-1-arch
Used distribution
Arch Linux
Linux kernel version used
6.5.5-arch1-1
CPU architectures issue was seen on
x86_64
Component
systemctl
Expected behaviour you didn't see
Units started with user manager would have specifiers referring to XDG variables (
%C, %E, %L, %S
) expand to reflect XDG settings.Unexpected behaviour you saw
Instead, systemd seems to have passed the XDG defaults to the unit (see attached log)
Steps to reproduce the problem
Fresh user, with
and
(note: for some reason, placing the unit under
$XDG_CONFIG_HOME/systemd/user/
rendered it visible tosystemd-analyze --user verify
but notsystemctl --user start
, but ran out of time diagnosing this)and
Additional program output to the terminal or log subsystem illustrating the issue
The text was updated successfully, but these errors were encountered: