GNU bug report logs - #55655
28.1; package.el no longers respects `user-emacs-directory'

Previous Next

Package: emacs;

Reported by: Shitikanth <shitikanth1 <at> gmail.com>

Date: Thu, 26 May 2022 11:09:02 UTC

Severity: normal

Found in version 28.1

Done: Stefan Kangas <stefankangas <at> gmail.com>

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 55655 in the body.
You can then email your comments to 55655 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-gnu-emacs <at> gnu.org:
bug#55655; Package emacs. (Thu, 26 May 2022 11:09:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Shitikanth <shitikanth1 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 26 May 2022 11:09:02 GMT) Full text and rfc822 format available.

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

From: Shitikanth <shitikanth1 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.1; package.el no longers respects `user-emacs-directory'
Date: Thu, 26 May 2022 16:37:48 +0530
Until emacs 27.2, package.el used to correctly pick `package-user-dir'
based on the value of `user-emacs-directory', but it now seems to ignore
it and defaults to "~/.emacs.d/elpa".

Demo:
    (setq user-emacs-directory "/tmp")
    (require 'package)
    (message "%s" package-user-dir)

Starting with "emacs -Q" this would output "~/.emacs.d/elpa".
Expected output: "/tmp/elpa" (as in emacs 27.2).

Based on git bisect, the offending commit seems to be 9973019764.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55655; Package emacs. (Thu, 26 May 2022 11:50:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Shitikanth <shitikanth1 <at> gmail.com>
Cc: 55655 <at> debbugs.gnu.org
Subject: Re: bug#55655: 28.1;
 package.el no longers respects `user-emacs-directory'
Date: Thu, 26 May 2022 14:49:08 +0300
> From: Shitikanth <shitikanth1 <at> gmail.com>
> Date: Thu, 26 May 2022 16:37:48 +0530
> 
> Until emacs 27.2, package.el used to correctly pick `package-user-dir'
> based on the value of `user-emacs-directory', but it now seems to ignore
> it and defaults to "~/.emacs.d/elpa".
> 
> Demo:
>     (setq user-emacs-directory "/tmp")
>     (require 'package)
>     (message "%s" package-user-dir)
> 
> Starting with "emacs -Q" this would output "~/.emacs.d/elpa".
> Expected output: "/tmp/elpa" (as in emacs 27.2).
> 
> Based on git bisect, the offending commit seems to be 9973019764.

Why do you set user-emacs-directory instead of setting
package-user-dir directly?  You are supposed to set the latter in your
early-init file.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55655; Package emacs. (Thu, 26 May 2022 13:21:02 GMT) Full text and rfc822 format available.

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

From: Shitikanth <shitikanth1 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 55655 <at> debbugs.gnu.org
Subject: Re: bug#55655: 28.1;
 package.el no longers respects `user-emacs-directory'
Date: Thu, 26 May 2022 18:49:53 +0530
I think almost all emacs packages follow the convention of setting
the location of their cache/configuration files by
calling`locate-user-emacs-file'.
This enables the user to just set the user-emacs-directory instead of
configuring all of them individually. (This works great for the use case of
wanting to put your emacs config in a location other than ~/.emacs.d or
even having multiple emacs configs.)

> (defcustom package-user-dir (locate-user-emacs-file "elpa")

Looking at the definition of `package-user-dir`, it ostensibly tries to
follow the same convention as well. It has just stopped working for
some reason since 9973019764, which is why I consider this a bug.

Is it actually intended behavior that `package-user-dir' should not
by default have the same value as (locate-user-emacs-file "elpa")?

On Thu, 26 May 2022 at 17:19, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > From: Shitikanth <shitikanth1 <at> gmail.com>
> > Date: Thu, 26 May 2022 16:37:48 +0530
> >
> > Until emacs 27.2, package.el used to correctly pick `package-user-dir'
> > based on the value of `user-emacs-directory', but it now seems to ignore
> > it and defaults to "~/.emacs.d/elpa".
> >
> > Demo:
> >     (setq user-emacs-directory "/tmp")
> >     (require 'package)
> >     (message "%s" package-user-dir)
> >
> > Starting with "emacs -Q" this would output "~/.emacs.d/elpa".
> > Expected output: "/tmp/elpa" (as in emacs 27.2).
> >
> > Based on git bisect, the offending commit seems to be 9973019764.
>
> Why do you set user-emacs-directory instead of setting
> package-user-dir directly?  You are supposed to set the latter in your
> early-init file.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55655; Package emacs. (Thu, 26 May 2022 13:56:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Shitikanth <shitikanth1 <at> gmail.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 55655 <at> debbugs.gnu.org
Subject: Re: bug#55655: 28.1;
 package.el no longers respects `user-emacs-directory'
Date: Thu, 26 May 2022 16:55:23 +0300
> From: Shitikanth <shitikanth1 <at> gmail.com>
> Date: Thu, 26 May 2022 18:49:53 +0530
> Cc: 55655 <at> debbugs.gnu.org
> 
> I think almost all emacs packages follow the convention of setting
> the location of their cache/configuration files by
> calling`locate-user-emacs-file'.
> This enables the user to just set the user-emacs-directory instead of
> configuring all of them individually. (This works great for the use case of
> wanting to put your emacs config in a location other than ~/.emacs.d or
> even having multiple emacs configs.)
> 
> > (defcustom package-user-dir (locate-user-emacs-file "elpa")
> 
> Looking at the definition of `package-user-dir`, it ostensibly tries to
> follow the same convention as well. It has just stopped working for
> some reason since 9973019764, which is why I consider this a bug.
> 
> Is it actually intended behavior that `package-user-dir' should not
> by default have the same value as (locate-user-emacs-file "elpa")?

Yes, but user-emacs-directory isn't supposed to be set, it is supposed
to be computed by Emacs early at startup, and then used for the rest
of the startup processing.

Stefan, am I missing something here?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55655; Package emacs. (Thu, 26 May 2022 15:30:03 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Shitikanth <shitikanth1 <at> gmail.com>
Cc: 55655 <at> debbugs.gnu.org
Subject: Re: bug#55655: 28.1; package.el no longers respects
 `user-emacs-directory'
Date: Thu, 26 May 2022 11:29:12 -0400
Shitikanth [2022-05-26 16:37:48] wrote:
> Until emacs 27.2, package.el used to correctly pick `package-user-dir'
> based on the value of `user-emacs-directory', but it now seems to ignore
> it and defaults to "~/.emacs.d/elpa".
>
> Demo:
>     (setq user-emacs-directory "/tmp")
>     (require 'package)
>     (message "%s" package-user-dir)
>
> Starting with "emacs -Q" this would output "~/.emacs.d/elpa".
> Expected output: "/tmp/elpa" (as in emacs 27.2).

That expectation is wrong, sadly, because it assumes that the
initialization of `package-user-dir` takes place during (require
'package), which is not the case because that variable is now
initialized earlier.

I understand it's a change, but it might be difficult to make this
specific recipe work the way you want without breaking other use-cases.

Could you give some more details about the use case that actually
affects you (I hope it's slightly different from the simplified recipe
shown above)?


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55655; Package emacs. (Fri, 27 May 2022 05:12:01 GMT) Full text and rfc822 format available.

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

From: Shitikanth <shitikanth1 <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 55655 <at> debbugs.gnu.org
Subject: Re: bug#55655: 28.1;
 package.el no longers respects `user-emacs-directory'
Date: Fri, 27 May 2022 10:40:53 +0530
>Could you give some more details about the use case that actually
affects you

I just have a couple of different configs and use them with
"emacs -Q --load $config_dir/init.el" and set the user-emacs-directory
early in "$config_dir/init.el". This was also the easiest way to try out
other people's configs without disturbing your own.

I guess I was always aware that this was an abuse of the init system,
so if this is an intended change, you can close the bug report.

On Thu, 26 May 2022 at 20:59, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
>
> Shitikanth [2022-05-26 16:37:48] wrote:
> > Until emacs 27.2, package.el used to correctly pick `package-user-dir'
> > based on the value of `user-emacs-directory', but it now seems to ignore
> > it and defaults to "~/.emacs.d/elpa".
> >
> > Demo:
> >     (setq user-emacs-directory "/tmp")
> >     (require 'package)
> >     (message "%s" package-user-dir)
> >
> > Starting with "emacs -Q" this would output "~/.emacs.d/elpa".
> > Expected output: "/tmp/elpa" (as in emacs 27.2).
>
> That expectation is wrong, sadly, because it assumes that the
> initialization of `package-user-dir` takes place during (require
> 'package), which is not the case because that variable is now
> initialized earlier.
>
> I understand it's a change, but it might be difficult to make this
> specific recipe work the way you want without breaking other use-cases.
>
> Could you give some more details about the use case that actually
> affects you (I hope it's slightly different from the simplified recipe
> shown above)?
>
>
>         Stefan
>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55655; Package emacs. (Fri, 27 May 2022 05:40:02 GMT) Full text and rfc822 format available.

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

From: Visuwesh <visuweshm <at> gmail.com>
To: Shitikanth <shitikanth1 <at> gmail.com>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 55655 <at> debbugs.gnu.org
Subject: Re: bug#55655: 28.1; package.el no longers respects
 `user-emacs-directory'
Date: Fri, 27 May 2022 11:09:05 +0530
[வெள்ளி மே 27, 2022] Shitikanth wrote:

>>Could you give some more details about the use case that actually
> affects you
>
> I just have a couple of different configs and use them with
> "emacs -Q --load $config_dir/init.el" and set the user-emacs-directory
> early in "$config_dir/init.el". This was also the easiest way to try out
> other people's configs without disturbing your own.
>
> I guess I was always aware that this was an abuse of the init system,
> so if this is an intended change, you can close the bug report.
>

FWIW, Emacs 29 added a --init-directory flag for these purposes.  Here's
the NEWS entry of the change,

    ** Emacs now supports setting 'user-emacs-directory' via '--init-directory'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55655; Package emacs. (Fri, 27 May 2022 06:04:02 GMT) Full text and rfc822 format available.

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

From: Shitikanth <shitikanth1 <at> gmail.com>
To: Visuwesh <visuweshm <at> gmail.com>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 55655 <at> debbugs.gnu.org
Subject: Re: bug#55655: 28.1;
 package.el no longers respects `user-emacs-directory'
Date: Fri, 27 May 2022 11:33:17 +0530
Great news! That's exactly what I needed

Thanks for pointing that out!

On Fri, 27 May 2022 at 11:09, Visuwesh <visuweshm <at> gmail.com> wrote:
>
> [வெள்ளி மே 27, 2022] Shitikanth wrote:
>
> >>Could you give some more details about the use case that actually
> > affects you
> >
> > I just have a couple of different configs and use them with
> > "emacs -Q --load $config_dir/init.el" and set the user-emacs-directory
> > early in "$config_dir/init.el". This was also the easiest way to try out
> > other people's configs without disturbing your own.
> >
> > I guess I was always aware that this was an abuse of the init system,
> > so if this is an intended change, you can close the bug report.
> >
>
> FWIW, Emacs 29 added a --init-directory flag for these purposes.  Here's
> the NEWS entry of the change,
>
>     ** Emacs now supports setting 'user-emacs-directory' via '--init-directory'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55655; Package emacs. (Fri, 27 May 2022 12:30:03 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Shitikanth <shitikanth1 <at> gmail.com>
Cc: 55655 <at> debbugs.gnu.org
Subject: Re: bug#55655: 28.1; package.el no longers respects
 `user-emacs-directory'
Date: Fri, 27 May 2022 08:29:43 -0400
>>Could you give some more details about the use case that actually
>> affects you
>
> I just have a couple of different configs and use them with
> "emacs -Q --load $config_dir/init.el" and set the user-emacs-directory
> early in "$config_dir/init.el". This was also the easiest way to try out
> other people's configs without disturbing your own.

I see... for this specific case `--init-directory` or `--user` might
work better.

> I guess I was always aware that this was an abuse of the init system,
> so if this is an intended change, you can close the bug report.

What you see is not exactly an "intended change" in the sense that it
would be good to make it behave the way you want to in your case.

But it's not straightforward: `package-user-directory` is now predefined
in the dumped Emacs.  Obviously it does need to be (re)computed at
startup (since your $HOME was not know when Emacs was dumped), but we do
that at the very beginning before processing `--eval` or loading
init files.  For your case to work properly, we'd need to delay the
(re)computation of `package-user-directory` to do it more lazily.

It doesn't seem impossible to do, but it might be tricky and risks
introducing other problems.

You can workaround the problem by explicitly calling

    (custom-reevaluate-setting 'package-user-directory)

after you've set `user-emacs-directory`.


        Stefan





Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Wed, 13 Sep 2023 01:42:02 GMT) Full text and rfc822 format available.

Notification sent to Shitikanth <shitikanth1 <at> gmail.com>:
bug acknowledged by developer. (Wed, 13 Sep 2023 01:42:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Shitikanth <shitikanth1 <at> gmail.com>
Cc: 55655-done <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 Visuwesh <visuweshm <at> gmail.com>
Subject: Re: bug#55655: 28.1;
 package.el no longers respects `user-emacs-directory'
Date: Tue, 12 Sep 2023 18:40:53 -0700
Shitikanth <shitikanth1 <at> gmail.com> writes:

> Great news! That's exactly what I needed
>
> Thanks for pointing that out!

Great.  I'm therefore closing this bug report.

> On Fri, 27 May 2022 at 11:09, Visuwesh <visuweshm <at> gmail.com> wrote:
>>
>> [வெள்ளி மே 27, 2022] Shitikanth wrote:
>>
>> >>Could you give some more details about the use case that actually
>> > affects you
>> >
>> > I just have a couple of different configs and use them with
>> > "emacs -Q --load $config_dir/init.el" and set the user-emacs-directory
>> > early in "$config_dir/init.el". This was also the easiest way to try out
>> > other people's configs without disturbing your own.
>> >
>> > I guess I was always aware that this was an abuse of the init system,
>> > so if this is an intended change, you can close the bug report.
>> >
>>
>> FWIW, Emacs 29 added a --init-directory flag for these purposes.  Here's
>> the NEWS entry of the change,
>>
>>     ** Emacs now supports setting 'user-emacs-directory' via '--init-directory'.




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

This bug report was last modified 191 days ago.

Previous Next


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