Subject: bug#55655: 28.1; package.el no longers respects `user-emacs-directory'

From: Stefan Monnier <[email-masked]>
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