Subject: bug#76924: 31.0.50; Wrong install location for systemd user unit file

From: Eli Zaretskii <[email-masked]>
Date: Tue, 11 Mar 2025 14:06:05 +0200

> From: Ulrich Müller <[email-masked]>
> Date: Mon, 10 Mar 2025 19:56:05 +0100
> 
> The top-level Makefile.in defines systemdunitdir=$(libdir)/systemd/user
> where libdir is taken from the --libdir configure option, so typically
> it will be /usr/local/lib64 or /usr/lib64 on a 64-bit system.
> 
> This appears to be wrong, the file should be installed in a fixed "lib"
> location, not $(libdir).
> 
> Reference:
> https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#id-1.8.5
> 
> Table 2 lists these locations:
> /usr/local/lib/systemd/user	User units installed by the administrator
> /usr/lib/systemd/user	User units installed by the distribution package manager
> 
> 
> Possible solutions:
> - Install in systemdunitdir=$(prefix)/lib/systemd/user
> - Add a --with-systemduserunitdir option (this was already suggested
>   in bug #16507 message #28)

The comment there says:

  # Where the etc/emacs.service file is to be installed.
  # The system value (typically /usr/lib/systemd/user) can be
  # obtained with: pkg-config --variable=systemduserunitdir systemd
  # but that does not respect configure's prefix.
  # It is not clear where we should install this file when
  # prefix != /usr (or /usr/local?) (eg for non-root installs).
  # Other options include ~/.config/systemd/user/,
  # $XDG_RUNTIME_DIR/systemd/user/
  # It seems the user may end up having to make a manual link...
  systemdunitdir=$(libdir)/systemd/user

So this isn't a simple mistake, but a deliberate decision.  We should
do more research before we override this.  For example: what do
distros do with this? do they really all use what you suggest?

Or maybe we should use pkg-config, at least if no --prefix was
specified at configure time?