I have this line in the early-init.el file:

(setq package-enable-at-startup nil)

and these lines in the init.el file:

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(setq package-archive-priorities '(("melpa"  . 100)
                                   ("gnu"    .  50)
                                   ("nongnu" .  25)))

(unless (package-installed-p 'use-package)
  (package-install 'use-package))

(use-package use-package
  (setq use-package-always-ensure t)
  (use-package use-package-ensure-system-package
    :ensure t))

I'm not sure if I understood correctly because I'm not a native English speaker but from what I read online it seemed to me that the (package-initialize) is not needed anymore in the init file since Emacs 27. However I'm not sure about it. Is that true?

I'm using Emacs 28.1. So, in my case should l get rid of the (package-initialize) line and set the package-enable-at-startup variable to t in early-init.el instead of nil? I'm not planning to use anything lower than Emacs 28 in the future.

  • A lot of what you read online may be out of date (check the date when it was written/updated): in many cases, things change in Emacs but the blogs are almost never updated to reflect such changes. You have to find trustworthy sources. For me, I trust the various manuals that are distributed with my Emacs and if I still have questions, I design and perform small experiments to try to figure out the answer(s). In some cases, I read the sources in order to figure out some things, but that can be time consuming. And even so, there may be errors in the manuals as well: "trust but verify" :-)
    – NickD
    Mar 13, 2023 at 15:49

1 Answer 1


It depends on what exactly you want to do. If what you want is to activate all your installed packages when Emacs starts up, then you have to do NOTHING: do not set package-enable-at-startup anywhere and do not call package-initialize anywhere (you still want to specify packages sources in package-archives of course, if you want more than the default gnu archive).

The Emacs manual section on packaging says:

   Installed packages are automatically made available by Emacs in all
subsequent sessions.  This happens at startup, before processing the
init file but after processing the early init file (*note Early Init
File::).  As an exception, Emacs does not make packages available at
startup if invoked with the ‘-q’ or ‘--no-init-file’ options (*note
Initial Options::).

   To keep Emacs from automatically making packages available at
startup, change the variable ‘package-enable-at-startup’ to ‘nil’.  You
must do this in the early init file, as the variable is read before
loading the regular init file.  Currently this variable cannot be set
via Customize.

package-enable-at-startup is set to t by default. You only have to worry about it if you don't want to activate your installed packages on startup (perhaps because you are debugging a problem in the packaging system - but that is a very special situation).

I also checked in Emacs 28.2 and the above should be valid in that as well. I don't have an Emacs 28.1 handy however, so I didn't check on that.

  • Thank you. I tried looking up the documentation but couldn't find anything. Now it makes sense. I think however that (require 'package) is still needed in the init.el. I don't think it is loaded by default.
    – Zoli
    Mar 13, 2023 at 14:57
  • AFAICT, it is loaded by default: (featurep 'package) returns t even in emaqcs -q where package activation is inhibited.
    – NickD
    Mar 13, 2023 at 15:31
  • For documentation, you should learn how to use Info: in this case, say C-h i g(emacs)packages: that takes you to the relevant chapter of the Emacs manual.
    – NickD
    Mar 13, 2023 at 15:37
  • Thank you. Interestingly things seem to work even if I remove (require 'package). Hmm.. That is strange.
    – Zoli
    Mar 13, 2023 at 15:51
  • I was wrong in my comment above that it is loaded by default: it is actually autoloaded, but the effect is pretty much the same.
    – NickD
    Mar 13, 2023 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.