Re: How to make Emacs use ELPA version of `compat'?

Stefan Monnier <[email protected]> Wed, 13 May 2026 10:35:29 -0400
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
[email protected] [2026-05-12 15:39:10] wrote:

> Stefan Monnier via Users list for the GNU Emacs text editor
> <[email protected]> writes:
>
>>>    1. emacs -Q
>>>    2. C-h v load-path RET
>>>       Confirm that ‘load-path’ contains only the Emacs
>>>       predefined directories.
>>>    3. M-x package-initialize RET
>>
>> Side note: you should never need to call `package-initialize` nowadays.
>> Call `package-activate-all` instead (which should be faster).
>>
>
> Will usage instructions be updated in the next version of
> Emacs?  In Emacs 30, (info "(elisp) Packaging Basics"):
>
>  -- Function: package-activate-all
>      This function makes the packages available to the current session.
>      The user option ‘package-load-list’ specifies which packages to
>      make available; by default, all installed packages are made
>      available.  *Note (emacs)Package Installation::.
>
>      In most cases, you should not need to call ‘package-activate-all’,
>      as this is done automatically during startup.
>      [...]
>
>  -- Command: package-initialize &optional no-activate
>      This function initializes Emacs's internal record of which packages
>      are installed, and then calls ‘package-activate-all’.

Thanks.  I just installed the patch below into `emacs-31.

> Since there are no details provided about "...initializes
> Emacs’s internal record...", it is opaque to users about
> which function/command to use when.

That's because the internal should stay internal, so ... just don't
use it.  It's a historical accident.

>    3. Call ‘package-initialize’ when...? 

Never is a good rule of thumb.
If you need to call it, please report it as a bug.


=== Stefan
package.patch (text/x-diff, 2.7 KB)
commit ce3098752cfb8cbb57c4f643088a2e6b16919ea7
Author: Stefan Monnier <[email protected]>
Date:   Wed May 13 10:34:03 2026 -0400

    doc: Remove long obsolete references to `package-initialize`
    
    Since Emacs-27, `package-initialize` is for internal use only,
    and callers should either call `package-activate-all` instead
    (cheaper and faster) or do nothing at all (because the other
    functions should trigger the needed initialization automatically
    as needed).
    
    * doc/lispref/package.texi (Packaging Basics): Delete `package-initialize`.
    
    * doc/misc/eglot.texi (Reporting bugs): Don't recommend using `package-initialize`.
    
    * doc/misc/org.org (Using Emacs packaging system): Simplify the command
    line since both `(require 'package)` and `(package-initialize)` are
    redundant here.

diff --git a/doc/lispref/package.texi b/doc/lispref/package.texi
index 8f3f5fe79b0..3097ed02345 100644
--- a/doc/lispref/package.texi
+++ b/doc/lispref/package.texi
@@ -133,15 +133,6 @@ Packaging Basics
 file (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
 @end defun
 
-@deffn Command package-initialize &optional no-activate
-This function initializes Emacs's internal record of which packages are
-installed, and then calls @code{package-activate-all}.
-
-The optional argument @var{no-activate}, if non-@code{nil}, causes
-Emacs to update its record of installed packages without actually
-making them available.
-@end deffn
-
 @node Simple Packages
 @section Simple Packages
 @cindex single file package
diff --git a/doc/misc/eglot.texi b/doc/misc/eglot.texi
index 0b6be34c41f..3deabb894c0 100644
--- a/doc/misc/eglot.texi
+++ b/doc/misc/eglot.texi
@@ -1969,7 +1969,7 @@ Reporting bugs
 
 @item
 Include a recipe to replicate the problem with @emph{a clean Emacs run}.
-The invocation @code{emacs -Q -f package-initialize} starts Emacs with
+The invocation @code{emacs -Q -f package-activate-all} starts Emacs with
 no configuration and initializes the ELPA packages.  A very minimal
 @file{.emacs} initialization file (10 lines or less) is also acceptable
 and good means to describe changes to variables.
diff --git a/doc/misc/org.org b/doc/misc/org.org
index ab0f8a9c1a6..8644109a6a1 100644
--- a/doc/misc/org.org
+++ b/doc/misc/org.org
@@ -125,7 +125,7 @@ To avoid interference with the built-in Org mode, you can use the
 command line (you need Emacs 30 or later):
 
 #+begin_src sh
-emacs -Q -batch -eval "(progn (require 'package) (package-initialize) (package-refresh-contents) (package-upgrade 'org))"
+emacs -Q -batch -eval "(progn (package-refresh-contents) (package-upgrade 'org))"
 #+end_src
 
 This approach has the advantage of isolating the upgrade process from