GNU bug report logs - #76924
31.0.50; Wrong install location for systemd user unit file

Previous Next

Package: emacs;

Reported by: Ulrich Müller <ulm <at> gentoo.org>

Date: Mon, 10 Mar 2025 18:57:02 UTC

Severity: normal

Found in version 31.0.50

Fixed in version 31.1

Done: Ulrich Müller <ulm <at> gentoo.org>

To reply to this bug, email your comments to 76924 AT debbugs.gnu.org.
There is no need to reopen the bug first.

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-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Mon, 10 Mar 2025 18:57:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ulrich Müller <ulm <at> gentoo.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 10 Mar 2025 18:57:02 GMT) Full text and rfc822 format available.

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

From: Ulrich Müller <ulm <at> gentoo.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; Wrong install location for systemd user unit file
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)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Tue, 11 Mar 2025 12:07:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ulrich Müller <ulm <at> gentoo.org>
Cc: 76924 <at> debbugs.gnu.org
Subject: Re: bug#76924: 31.0.50;
 Wrong install location for systemd user unit file
Date: Tue, 11 Mar 2025 14:06:05 +0200
> From: Ulrich Müller <ulm <at> gentoo.org>
> 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?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Tue, 11 Mar 2025 13:35:02 GMT) Full text and rfc822 format available.

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

From: Ulrich Müller <ulm <at> gentoo.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Ulrich Müller <ulm <at> gentoo.org>, 76924 <at> debbugs.gnu.org
Subject: Re: bug#76924: 31.0.50; Wrong install location for systemd user
 unit file
Date: Tue, 11 Mar 2025 14:34:20 +0100
>>>>> On Tue, 11 Mar 2025, Eli Zaretskii wrote:

> 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?

Gentoo removes the emacs.service file from Emacs' install image and
installs it in /usr/lib/systemd/user instead.

IIUC Debian installs system unit files in the /lib/systemd/system
directory, see https://wiki.debian.org/systemd. The article doesn't
mention user files, but the corresponding location would be
/lib/systemd/user (i.e. _not_ /lib64).

(Note that systemd no longer supports the concept of separate /lib and
/usr/lib, i.e. /lib is a symlink to /usr/lib and it doesn't matter if
the prefix is / or /usr.)

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

systemd.pc has this
(https://github.com/systemd/systemd/blob/cd20d48c69f9e586de914e1facf33b11122477ae/src/core/systemd.pc.in#L34):

   systemd_user_unit_dir=${prefix}/lib/systemd/user
   systemduserunitdir=${systemd_user_unit_dir}

So depending on the prefix, that would be /lib or /usr/lib (which are
equivalent, see above).

Maybe the cleanest solution would be to ask pkg-config (after all,
systemd must find these files), with $(prefix)/lib/systemd/user as
fallback location.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Tue, 11 Mar 2025 13:50:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ulrich Müller <ulm <at> gentoo.org>
Cc: 76924 <at> debbugs.gnu.org
Subject: Re: bug#76924: 31.0.50; Wrong install location for systemd user
 unit file
Date: Tue, 11 Mar 2025 15:48:59 +0200
> From: Ulrich Müller <ulm <at> gentoo.org>
> Cc: Ulrich Müller <ulm <at> gentoo.org>,  76924 <at> debbugs.gnu.org
> Date: Tue, 11 Mar 2025 14:34:20 +0100
> 
> > Or maybe we should use pkg-config, at least if no --prefix was
> > specified at configure time?
> 
> systemd.pc has this
> (https://github.com/systemd/systemd/blob/cd20d48c69f9e586de914e1facf33b11122477ae/src/core/systemd.pc.in#L34):
> 
>    systemd_user_unit_dir=${prefix}/lib/systemd/user
>    systemduserunitdir=${systemd_user_unit_dir}
> 
> So depending on the prefix, that would be /lib or /usr/lib (which are
> equivalent, see above).
> 
> Maybe the cleanest solution would be to ask pkg-config (after all,
> systemd must find these files), with $(prefix)/lib/systemd/user as
> fallback location.

SGTM, thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Tue, 11 Mar 2025 14:39:02 GMT) Full text and rfc822 format available.

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

From: Ulrich Müller <ulm <at> gentoo.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Ulrich Müller <ulm <at> gentoo.org>, 76924 <at> debbugs.gnu.org
Subject: Re: bug#76924: 31.0.50; Wrong install location for systemd user
 unit file
Date: Tue, 11 Mar 2025 15:38:25 +0100
>>>>> On Tue, 11 Mar 2025, Eli Zaretskii wrote:

>> Maybe the cleanest solution would be to ask pkg-config (after all,
>> systemd must find these files), with $(prefix)/lib/systemd/user as
>> fallback location.

> SGTM, thanks.

Sorry, I had a thinko there. Asking pkg-config isn't such a good idea.
Imagine someone installing with prefix=/usr/local, we would then install
the unit file in a stray location outside prefix. It is even worse for
non-root installs where the dir may not even be writable.

So I come back to my original solution of $(prefix)/lib/systemd/user,
which just avoids "lib64" in favour of "lib".

Or we could add a configure option (like --with-systemduserunitdir),
but maybe that would be over-engineered.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Tue, 11 Mar 2025 17:24:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ulrich Müller <ulm <at> gentoo.org>
Cc: 76924 <at> debbugs.gnu.org
Subject: Re: bug#76924: 31.0.50; Wrong install location for systemd user
 unit file
Date: Tue, 11 Mar 2025 19:22:06 +0200
> From: Ulrich Müller <ulm <at> gentoo.org>
> Cc: Ulrich Müller <ulm <at> gentoo.org>,  76924 <at> debbugs.gnu.org
> Date: Tue, 11 Mar 2025 15:38:25 +0100
> 
> >>>>> On Tue, 11 Mar 2025, Eli Zaretskii wrote:
> 
> >> Maybe the cleanest solution would be to ask pkg-config (after all,
> >> systemd must find these files), with $(prefix)/lib/systemd/user as
> >> fallback location.
> 
> > SGTM, thanks.
> 
> Sorry, I had a thinko there. Asking pkg-config isn't such a good idea.
> Imagine someone installing with prefix=/usr/local, we would then install
> the unit file in a stray location outside prefix.

Sorry, I don't understand: if prefix=/usr/local, then
$(prefix)/lib/systemd/user gives us /usr/local/lib/systemd/user, which
is what you wanted, no?  Or what did I miss?

> It is even worse for non-root installs where the dir may not even be
> writable.

For these, we could ask users to use --with-systemduserunitdir.  But
"normal" installs should not need to specify standard directories.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Tue, 11 Mar 2025 17:40:02 GMT) Full text and rfc822 format available.

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

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Ulrich Müller <ulm <at> gentoo.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 76924 <at> debbugs.gnu.org
Subject: Re: bug#76924: 31.0.50; Wrong install location for systemd user
 unit file
Date: Tue, 11 Mar 2025 18:39:12 +0100
On Mär 11 2025, Ulrich Müller wrote:

> Sorry, I had a thinko there. Asking pkg-config isn't such a good idea.
> Imagine someone installing with prefix=/usr/local, we would then install
> the unit file in a stray location outside prefix. It is even worse for
> non-root installs where the dir may not even be writable.

But the unit file needs to be installed in a location searched by
systemd, so it needs to follow systemd's idea of prefix.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Tue, 11 Mar 2025 17:51:01 GMT) Full text and rfc822 format available.

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

From: Ulrich Müller <ulm <at> gentoo.org>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: Ulrich Müller <ulm <at> gentoo.org>,
 Eli Zaretskii <eliz <at> gnu.org>, 76924 <at> debbugs.gnu.org
Subject: Re: bug#76924: 31.0.50; Wrong install location for systemd user
 unit file
Date: Tue, 11 Mar 2025 18:50:36 +0100
>>>>> On Tue, 11 Mar 2025, Andreas Schwab wrote:

> On Mär 11 2025, Ulrich Müller wrote:
>> Sorry, I had a thinko there. Asking pkg-config isn't such a good idea.
>> Imagine someone installing with prefix=/usr/local, we would then install
>> the unit file in a stray location outside prefix. It is even worse for
>> non-root installs where the dir may not even be writable.

> But the unit file needs to be installed in a location searched by
> systemd, so it needs to follow systemd's idea of prefix.

More precisely, they need to be installed in a directory that is in
systemd's search path for unit files. Which includes /usr/lib,
/usr/local/lib, /etc, and a few others.

Looks like we should have a configure option for it then?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Wed, 12 Mar 2025 12:24:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ulrich Müller <ulm <at> gentoo.org>
Cc: schwab <at> linux-m68k.org, 76924 <at> debbugs.gnu.org
Subject: Re: bug#76924: 31.0.50; Wrong install location for systemd user
 unit file
Date: Wed, 12 Mar 2025 14:23:17 +0200
> From: Ulrich Müller <ulm <at> gentoo.org>
> Cc: Ulrich Müller <ulm <at> gentoo.org>,  Eli Zaretskii
>  <eliz <at> gnu.org>,
>   76924 <at> debbugs.gnu.org
> Date: Tue, 11 Mar 2025 18:50:36 +0100
> 
> >>>>> On Tue, 11 Mar 2025, Andreas Schwab wrote:
> 
> > On Mär 11 2025, Ulrich Müller wrote:
> >> Sorry, I had a thinko there. Asking pkg-config isn't such a good idea.
> >> Imagine someone installing with prefix=/usr/local, we would then install
> >> the unit file in a stray location outside prefix. It is even worse for
> >> non-root installs where the dir may not even be writable.
> 
> > But the unit file needs to be installed in a location searched by
> > systemd, so it needs to follow systemd's idea of prefix.
> 
> More precisely, they need to be installed in a directory that is in
> systemd's search path for unit files. Which includes /usr/lib,
> /usr/local/lib, /etc, and a few others.
> 
> Looks like we should have a configure option for it then?

Is there no way of knowing what is systemd's idea of prefix?  If not,
I guess a configure option will have to do, but the question of the
default still stands, no?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Wed, 12 Mar 2025 13:16:02 GMT) Full text and rfc822 format available.

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

From: Ulrich Müller <ulm <at> gentoo.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Ulrich Müller <ulm <at> gentoo.org>, schwab <at> linux-m68k.org,
 76924 <at> debbugs.gnu.org
Subject: Re: bug#76924: 31.0.50; Wrong install location for systemd user
 unit file
Date: Wed, 12 Mar 2025 14:15:23 +0100
>>>>> On Wed, 12 Mar 2025, Eli Zaretskii wrote:

> Is there no way of knowing what is systemd's idea of prefix?

I think that for the majority of installations it would be prefix=/usr.

> If not, I guess a configure option will have to do, but the question
> of the default still stands, no?

Presumably the most common use cases will be:

- Distros building an Emacs package. These should make sure that prefix
  is the same for all their packages. So, installing in $(prefix)/lib
  will be The Right Thing and no option is needed.

- Users compiling Emacs from the release tarball or from Git. For these
  we don't really know what the prefix is, it could be /usr/local or
  some location under their home dir. I believe an option would be
  useful here.

  Not entirely sure about the default, but I'd go with $(prefix)/lib
  also for this case, because: a) /usr/local/lib is in systemd's search
  path, which covers one of the more common cases, and b) hardcoded
  /usr/lib (systemd's prefix) may not be writable for the user.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Wed, 12 Mar 2025 15:20:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ulrich Müller <ulm <at> gentoo.org>
Cc: schwab <at> linux-m68k.org, 76924 <at> debbugs.gnu.org
Subject: Re: bug#76924: 31.0.50; Wrong install location for systemd user
 unit file
Date: Wed, 12 Mar 2025 17:18:59 +0200
> From: Ulrich Müller <ulm <at> gentoo.org>
> Cc: Ulrich Müller <ulm <at> gentoo.org>,  schwab <at> linux-m68k.org,
>   76924 <at> debbugs.gnu.org
> Date: Wed, 12 Mar 2025 14:15:23 +0100
> 
> >>>>> On Wed, 12 Mar 2025, Eli Zaretskii wrote:
> 
> > Is there no way of knowing what is systemd's idea of prefix?
> 
> I think that for the majority of installations it would be prefix=/usr.
> 
> > If not, I guess a configure option will have to do, but the question
> > of the default still stands, no?
> 
> Presumably the most common use cases will be:
> 
> - Distros building an Emacs package. These should make sure that prefix
>   is the same for all their packages. So, installing in $(prefix)/lib
>   will be The Right Thing and no option is needed.
> 
> - Users compiling Emacs from the release tarball or from Git. For these
>   we don't really know what the prefix is, it could be /usr/local or
>   some location under their home dir. I believe an option would be
>   useful here.
> 
>   Not entirely sure about the default, but I'd go with $(prefix)/lib
>   also for this case, because: a) /usr/local/lib is in systemd's search
>   path, which covers one of the more common cases, and b) hardcoded
>   /usr/lib (systemd's prefix) may not be writable for the user.

OK, thanks.  Before we decide what to do, would it be possibly to see
what other projects do with systemd files?  (Assuming there are other
projects which install files for systemd's use.)  I'd like to be sure
we are not reinventing the wheel here, if some accepted solution
already exists.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Wed, 12 Mar 2025 16:38:01 GMT) Full text and rfc822 format available.

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

From: Ulrich Müller <ulm <at> gentoo.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Ulrich Müller <ulm <at> gentoo.org>, schwab <at> linux-m68k.org,
 76924 <at> debbugs.gnu.org
Subject: Re: bug#76924: 31.0.50; Wrong install location for systemd user
 unit file
Date: Wed, 12 Mar 2025 17:36:46 +0100
>>>>> On Wed, 12 Mar 2025, Eli Zaretskii wrote:

>> Presumably the most common use cases will be:
>> 
>> - Distros building an Emacs package. These should make sure that
>>   prefix is the same for all their packages. So, installing in
>>   $(prefix)/lib will be The Right Thing and no option is needed.
>> 
>> - Users compiling Emacs from the release tarball or from Git. For
>>   these we don't really know what the prefix is, it could be
>>   /usr/local or some location under their home dir. I believe an
>>   option would be useful here.
>> 
>>   Not entirely sure about the default, but I'd go with $(prefix)/lib
>>   also for this case, because: a) /usr/local/lib is in systemd's
>>   search path, which covers one of the more common cases, and
>>   b) hardcoded /usr/lib (systemd's prefix) may not be writable for
>>   the user.

> OK, thanks. Before we decide what to do, would it be possibly to see
> what other projects do with systemd files? (Assuming there are other
> projects which install files for systemd's use.) I'd like to be sure
> we are not reinventing the wheel here, if some accepted solution
> already exists.

So I did some reasearch (not at all comprehensive, but should be enough
to get an idea how things are typically done):

blueman:
  configure option --with-systemduserunitdir

GNOME:
  Meson option:
  option('systemduserunitdir', type: 'string', value: '', description: 'custom directory for systemd user units, or \'no\' to disable')

KDE:
  CMake installs into ${KDE_INSTALL_SYSTEMDUSERUNITDIR} which is defined
  by KDE Frameworks' extra-cmake-modules package

XFCE:
  configure.ac defines location based on $(prefix):
  systemd_userdir = $(prefix)/lib/systemd/user

libvirt:
  Meson option (for system unit file):
  option('unitdir', type: 'string', value: '', description: 'directory for systemd unit files')

PAM:
  Meson option (for system unit file):
  option('systemdunitdir', type: 'string', description: 'systemd service directory')


From this, I would conclude:

- Most packages have the location configurable. The only exception in
  above list is XFCE which uses $(prefix)/lib/systemd/user.

- The name of the option isn't standardised, but variations of
  "--with-systemduserunitdir" or "systemduserunitdir" are what I see
  most often.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Wed, 12 Mar 2025 16:55:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ulrich Müller <ulm <at> gentoo.org>
Cc: schwab <at> linux-m68k.org, 76924 <at> debbugs.gnu.org
Subject: Re: bug#76924: 31.0.50; Wrong install location for systemd user
 unit file
Date: Wed, 12 Mar 2025 18:53:47 +0200
> From: Ulrich Müller <ulm <at> gentoo.org>
> Cc: Ulrich Müller <ulm <at> gentoo.org>,  schwab <at> linux-m68k.org,
>   76924 <at> debbugs.gnu.org
> Date: Wed, 12 Mar 2025 17:36:46 +0100
> 
> >>>>> On Wed, 12 Mar 2025, Eli Zaretskii wrote:
> 
> So I did some reasearch (not at all comprehensive, but should be enough
> to get an idea how things are typically done):
> 
> blueman:
>   configure option --with-systemduserunitdir
> 
> GNOME:
>   Meson option:
>   option('systemduserunitdir', type: 'string', value: '', description: 'custom directory for systemd user units, or \'no\' to disable')
> 
> KDE:
>   CMake installs into ${KDE_INSTALL_SYSTEMDUSERUNITDIR} which is defined
>   by KDE Frameworks' extra-cmake-modules package
> 
> XFCE:
>   configure.ac defines location based on $(prefix):
>   systemd_userdir = $(prefix)/lib/systemd/user
> 
> libvirt:
>   Meson option (for system unit file):
>   option('unitdir', type: 'string', value: '', description: 'directory for systemd unit files')
> 
> PAM:
>   Meson option (for system unit file):
>   option('systemdunitdir', type: 'string', description: 'systemd service directory')
> 
> 
> >From this, I would conclude:
> 
> - Most packages have the location configurable. The only exception in
>   above list is XFCE which uses $(prefix)/lib/systemd/user.
> 
> - The name of the option isn't standardised, but variations of
>   "--with-systemduserunitdir" or "systemduserunitdir" are what I see
>   most often.

Thanks.  So I guess we will add a configure time option with
$(prefix)/lib/systemd/user as fallback?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Wed, 12 Mar 2025 17:44:02 GMT) Full text and rfc822 format available.

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

From: Ulrich Müller <ulm <at> gentoo.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Ulrich Müller <ulm <at> gentoo.org>, schwab <at> linux-m68k.org,
 76924 <at> debbugs.gnu.org
Subject: Re: bug#76924: 31.0.50; Wrong install location for systemd user
 unit file
Date: Wed, 12 Mar 2025 18:43:34 +0100
>>>>> On Wed, 12 Mar 2025, Eli Zaretskii wrote:

> Thanks. So I guess we will add a configure time option with
> $(prefix)/lib/systemd/user as fallback?

Yes, option --with-systemduserunitdir with fallback as mentioned.

I'll try to come up with a patch before the end of the week.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Thu, 13 Mar 2025 11:23:01 GMT) Full text and rfc822 format available.

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

From: Ulrich Müller <ulm <at> gentoo.org>
To: 76924 <at> debbugs.gnu.org
Cc: Ulrich Müller <ulm <at> gentoo.org>, schwab <at> linux-m68k.org,
 Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#76924: 31.0.50; Wrong install location for systemd user
 unit file
Date: Thu, 13 Mar 2025 12:22:40 +0100
[Message part 1 (text/plain, inline)]
Proposed patch attached, please review.

[0001-New-configure-option-with-systemduserunitdir.patch (text/plain, inline)]
From 19232af5cb08a321dde60fd59e92c8b30203d7f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ulrich=20M=C3=BCller?= <ulm <at> gentoo.org>
Date: Thu, 13 Mar 2025 12:16:37 +0100
Subject: [PATCH] New configure option --with-systemduserunitdir

* configure.ac (systemduserunitdir): New variable and option.
* Makefile.in (systemduserunitdir): New, set by configure.
(install-etc, uninstall): Don't install emacs.service when
systemduserunitdir is unspecified.
* etc/NEWS: Announce the new configure option.  (Bug#76924)
---
 Makefile.in  | 22 +++++++++-------------
 configure.ac | 16 ++++++++++++++++
 etc/NEWS     |  5 +++++
 3 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index ca6d991bce6..0ba11c9aa5b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -160,7 +160,7 @@ sharedstatedir=
 # a subdirectory of this.
 libexecdir=@libexecdir@
 
-# Currently only used for the systemd service file.
+# Where to install object code libraries.  Used for ELN_DESTDIR.
 libdir=@libdir@
 
 # Where to install emacs-module.h.
@@ -207,15 +207,7 @@ desktopdir=
 metainfodir=$(datarootdir)/metainfo
 
 # 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
+systemduserunitdir=@systemduserunitdir@
 
 # Where the etc/images/icons/hicolor directory is to be installed.
 icondir=$(datarootdir)/icons
@@ -886,14 +878,16 @@ install-etc:
 	  ${srcdir}/etc/emacs.metainfo.xml > $${tmp}; \
 	${INSTALL_DATA} $${tmp} "$(DESTDIR)${metainfodir}/${EMACS_NAME}.metainfo.xml"; \
 	rm -f $${tmp}
-	umask 022; $(MKDIR_P) "$(DESTDIR)$(systemdunitdir)"
+  ifneq ($(systemduserunitdir),)
+	umask 022; $(MKDIR_P) "$(DESTDIR)$(systemduserunitdir)"
 	tmp=etc/emacs.tmpservice; rm -f $${tmp}; \
 	sed -e '/^##/d' \
 	  -e "/^Documentation/ s/emacs(1)/${EMACS_NAME}(1)/" \
 	  -e "/^ExecStart/ s|emacs|${bindir}/${EMACS}|" \
 	  ${srcdir}/etc/emacs.service > $${tmp}; \
-	$(INSTALL_DATA) $${tmp} "$(DESTDIR)$(systemdunitdir)/${EMACS_NAME}.service"; \
+	$(INSTALL_DATA) $${tmp} "$(DESTDIR)$(systemduserunitdir)/${EMACS_NAME}.service"; \
 	rm -f $${tmp}
+  endif
 	thisdir=`pwd -P`; \
 	cd ${iconsrcdir} || exit 1; umask 022 ; \
 	for dir in */*/apps */*/mimetypes; do \
@@ -977,7 +971,9 @@ uninstall:
 	fi)
 	-rm -f "$(DESTDIR)${desktopdir}/${EMACS_NAME}.desktop"
 	-rm -f "$(DESTDIR)${metainfodir}/${EMACS_NAME}.metainfo.xml"
-	-rm -f "$(DESTDIR)$(systemdunitdir)/${EMACS_NAME}.service"
+  ifneq ($(systemduserunitdir),)
+	-rm -f "$(DESTDIR)$(systemduserunitdir)/${EMACS_NAME}.service"
+  endif
   ifneq (,$(use_gamedir))
 	for file in snake-scores tetris-scores; do \
 	  file="$(DESTDIR)${gamedir}/$${file}"; \
diff --git a/configure.ac b/configure.ac
index 4a7f326ab2b..033f1dc09ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -481,6 +481,22 @@ AC_DEFUN
 DUMPING=$with_dumping
 AC_SUBST([DUMPING])
 
+dnl Where the etc/emacs.service file is to be installed.
+dnl We use $(prefix)/lib/systemd/user as default, but this may not be
+dnl in systemd's search path when prefix is neither /usr nor /usr/local.
+dnl In that case (e.g. for non-root installs) the location can be
+dnl specified with the configure option.  (Bug#76924)
+AC_ARG_WITH([systemduserunitdir],
+  [AS_HELP_STRING([--with-systemduserunitdir=DIR],
+    [directory for systemd user unit file;
+    default 'PREFIX/usr/lib/systemd/user'])],
+  [systemduserunitdir=${withval}],
+  [systemduserunitdir='${prefix}/lib/systemd/user'])
+if test "${systemduserunitdir}" = "no"; then
+  systemduserunitdir=''
+fi
+AC_SUBST([systemduserunitdir])
+
 dnl FIXME currently it is not the last.
 dnl This should be the last --with option, because --with-x is
 dnl added later on when we find the file name of X, and it's best to
diff --git a/etc/NEWS b/etc/NEWS
index d79080c94e8..e7f13bbc567 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -37,6 +37,11 @@ host system supports SSE2) or '-fno-tree-sra' (if not).  These GCC
 options work around GCC bug 58416, which can cause Emacs to behave
 incorrectly in rare cases.
 
+---
+** New configure option '--with-systemduserunitdir'.
+This allows to specify the directory where the user unit file for
+systemd is installed; default is '${prefix}/usr/lib/systemd/user'.
+
 
 * Startup Changes in Emacs 31.1
 
-- 
2.48.1


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Thu, 13 Mar 2025 14:40:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ulrich Müller <ulm <at> gentoo.org>
Cc: schwab <at> linux-m68k.org, 76924 <at> debbugs.gnu.org
Subject: Re: bug#76924: 31.0.50; Wrong install location for systemd user
 unit file
Date: Thu, 13 Mar 2025 16:39:39 +0200
> From: Ulrich Müller <ulm <at> gentoo.org>
> Cc: Ulrich Müller <ulm <at> gentoo.org>, Eli Zaretskii
>  <eliz <at> gnu.org>,
>   schwab <at> linux-m68k.org
> Date: Thu, 13 Mar 2025 12:22:40 +0100
> 
> Proposed patch attached, please review.

Thanks.  This LGTM, but maybe it would be slightly better to have
references to the URLs where the standard places are documented,
instead of the reference to discussion of this bug?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76924; Package emacs. (Fri, 14 Mar 2025 07:04:02 GMT) Full text and rfc822 format available.

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

From: Ulrich Müller <ulm <at> gentoo.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Ulrich Müller <ulm <at> gentoo.org>, schwab <at> linux-m68k.org,
 76924 <at> debbugs.gnu.org
Subject: Re: bug#76924: 31.0.50; Wrong install location for systemd user
 unit file
Date: Fri, 14 Mar 2025 08:03:05 +0100
>>>>> On Thu, 13 Mar 2025, Eli Zaretskii wrote:

> Thanks.  This LGTM, but maybe it would be slightly better to have
> references to the URLs where the standard places are documented,
> instead of the reference to discussion of this bug?

Comment updated, and pushed to master.




bug marked as fixed in version 31.1, send any further explanations to 76924 <at> debbugs.gnu.org and Ulrich Müller <ulm <at> gentoo.org> Request was from Ulrich Müller <ulm <at> gentoo.org> to control <at> debbugs.gnu.org. (Fri, 14 Mar 2025 07:06:02 GMT) Full text and rfc822 format available.

This bug report was last modified 6 days ago.

Previous Next


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