Oluwabunmi Akapo
Oluwabunmi Akapo

Reputation: 1

EMACS Warning (package): Unnecessary call to ‘package-initialize’ in init file

I am new to coding started just a month ago. I am preparing ahead for my bootcamp with EMACS. I followed a tutorial and was told to initialize package. The code I used was:

(package-initialize)

(require 'package)
(add-to-list 'package-archives ' ("melpa" . "http://melpa.org/packages/"))
(package-initialize)

I keep getting warning (package): Unnecessary call to ‘package-initialize’ in init file and I don't know what to do next or how to solve it.

Upvotes: 0

Views: 1300

Answers (1)

Marc Legendre
Marc Legendre

Reputation: 43

According to the emacs changelog 1, you can get rid of the call to package-initialize if you use emacs >= 27:

Installed packages are now activated before loading the init file. As a result of this change, it is no longer necessary to call 'package-initialize' in your init file.

Also,

if you want to ensure that your init file is still compatible with earlier versions of Emacs, change it to:

(when (< emacs-major-version 27)
  (package-initialize))

Upvotes: 4

Related Questions