6

I tried to install emacs and in an attempt to install MELPA, tried:

(this is my init.el file)

(package-initialize)
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))

(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
                    (not (gnutls-available-p))))
       (proto (if no-ssl "http" "https")))
  (add-to-list 'package-archives
               (cons "melpa" (concat proto "://melpa.org/packages/")) t))
(package-initialize)

When I tried running the following commands M-x package-initialize then M-x package-refresh-contents, it said that it Failed to download 'gnu' archive. Is there anyway of getting around this?

I'm using MacOS and using emacs version 26.2.

3

Add the following before package-initialize:

(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")

This is apparently a bug in Emacs 26.2 for MacOS. I found this solution in this reddit thread.

1

First of all run emacs with --debug-init from your terminal and check if complains about being unable to verify the elpa archive due to an invalid key. If that is the case, copy the public key displayed to you.

I ran into this problem because the GPG keys used by the ELPA package manager to verify authenticity of packages downloaded from the GNU ELPA archive have a limited validity in time (for example, the first key was valid until Sep 2019 only).

If your keys are already too old, causing signature verification errors when installing packages you can do the following:

gpg --homedir ~/.emacs.d/elpa/gnupg --receive-keys C433554766D3DDC64221BFAA066DAFCB81E42C40

You should replace the key with the value you copied from the debug log

I found this package to hopefully avoid this problem when the certificates change the next time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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