Skip to content

Specifiers in user units don't use environment.d values #29414

@hseg

Description

@hseg

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

#~/.config/environment.d/00-xdg.conf
LOCALDIR=/home/test/.local
XDG_CONFIG_HOME=${LOCALDIR}/etc
XDG_CACHE_HOME=${LOCALDIR}/var/cache
XDG_STATE_HOME=${LOCALDIR}/var/state

and

#~/.config/systemd/user/check-xdg.service
[Service]
Type=oneshot
ExecStart=echo "XDG_CACHE_HOME=" %C
ExecStart=echo "XDG_CONFIG_HOME=" %E
ExecStart=echo "XDG_STATE_HOME/log=" %L
ExecStart=echo "XDG_STATE_HOME=" %S

[Install]
WantedBy=default.target

(note: for some reason, placing the unit under $XDG_CONFIG_HOME/systemd/user/ rendered it visible to systemd-analyze --user verify but not systemctl --user start, but ran out of time diagnosing this)

and

#~/check-xdg.sh
echo "XDG_CACHE_HOME=$XDG_CACHE_HOME"
echo "XDG_CONFIG_HOME=$XDG_CONFIG_HOME"
echo "XDG_STATE_HOME/log=$XDG_STATE_HOME/log"
echo "XDG_STATE_HOME=$XDG_STATE_HOME"

Additional program output to the terminal or log subsystem illustrating the issue

Oct 02 22:28:45 telcontar systemd[448300]: Starting check-xdg.service...
Oct 02 22:28:45 telcontar echo[448743]: XDG_CACHE_HOME=/home/test/.cache
Oct 02 22:28:45 telcontar echo[448745]: XDG_CONFIG_HOME=/home/test/.config
Oct 02 22:28:45 telcontar echo[448747]: XDG_STATE_HOME/log=/home/test/.local/state/log
Oct 02 22:28:45 telcontar echo[448749]: XDG_STATE_HOME=/home/test/.local/state
Oct 02 22:28:45 telcontar systemd[448300]: Finished check-xdg.service.

--- below is check-xdg.sh output
XDG_CACHE_HOME=/home/test/.local/var/cache
XDG_CONFIG_HOME=/home/test/.local/etc
XDG_STATE_HOME/log=/home/test/.local/var/state/log
XDG_STATE_HOME=/home/test/.local/var/state

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions