1

I'm currently using Ubuntu 18.04, and trying out Emacs for the first time. However, whenever I run the command package-refresh-contents, I get the the follow error:

Failed to download 'gnu' archive

This is my ~/.emacs.d/init.el file:

(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
;(setq package-check-signature nil)

; Set up melpa package repository
(require 'package)
(setq package-enable-at-startup nil)

(add-to-list 'package-archives
         '("gnu", "https://elpa.gnu.org/packages/")
         '("melpa", "https://melpa.org/packages/"))

(package-initialize)

These are the steps I've tried so far:

  1. Upgraded from Emacs 26.2 to 26.3. According to this Reddit thread, this was supposedly fixed in Emacs 26.3. Since I'm using Kelley PPA to download Emacs, I had to upgrade from Ubuntu 16.04 to 18.04 to get Emacs 26.3, and it still didn't fix the issue.
  2. Set (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") as suggested here.
  3. Set (setq package-check-signature nil) as suggested here.
  4. Changed the URLs from https to http.

I've found no other suggestions when I searched online. Any help would be appreciated.

Updating with error message printed in Messages buffer when running the command package-refresh-contents after starting emacs with the flag --debug-init:

For information about GNU Emacs and the GNU system, type C-h C-a.
Importing package-keyring.gpg...done Contacting host: elpa.gnu.org:443
gnutls.el: (err=[-50] The request is invalid.) boot: (:priority NORMAL:-VERS-TLS1.3 :hostname elpa.gnu.org :loglevel 0 :min-prime-bits 256 :trustfiles (/etc/ssl/certs/ca-certificates.crt) :crlfiles nil :keylist nil :verify-flags nil :verify-error nil :callbacks nil)
Failed to download ‘gnu’ archive. [2 times]
You can run the command ‘package-refresh-contents’ with M-x pa-r- RET
Failed to download ‘gnu’ archive.

Updating with error message after removing the gnutls-algorithm-priority setting:

For information about GNU Emacs and the GNU system, type C-h C-a.
delete-backward-char: Text is read-only [4 times]
Importing package-keyring.gpg...done
Contacting host: elpa.gnu.org:443 [2 times]
Failed to download ‘gnu’ archive.
You can run the command ‘package-refresh-contents’ with M-x pa-r- RET
Failed to download ‘gnu’ archive.

Updated with debugger info after running command toggle-debug-on-error and then running package-refresh-contents:

Debugger entered--Lisp error: (wrong-type-argument stringp ((\, "https://elpa.gnu.org/packages/")))
string-match("\`https?:" ((\, "https://elpa.gnu.org/packages/")) nil)
package--download-one-archive(("gnu" (\, "https://elpa.gnu.org/packages/")) "archive-contents" nil)
package--download-and-read-archives(nil)
package-refresh-contents()
funcall-interactively(package-refresh-contents)
call-interactively(package-refresh-contents record nil)
command-execute(package-refresh-contents record)
execute-extended-command(nil "package-refresh-contents" "package-refr")
funcall-interactively(execute-extended-command nil "package-refresh-contents" "package-refr")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)

  • 1
    Do you get a backtrace if you use emacs --debug-init? Is there any text in the *Messages* buffer? – npostavs Oct 12 at 2:07
  • @npostavs I've updated the question with the error message printed in the Messages. I'm not able to figure out what I need to do based on the error message though. – gjvatsalya Oct 14 at 15:06
  • I think that message indicates your libgnutls version is too old to understand "NORMAL:-VERS-TLS1.3", try removing that setting (and it shouldn't be needed in Emacs 26.3 regardless). – npostavs Oct 14 at 15:11
  • @npostavs I removed (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"), and I still get the same error. Although the Messages buffer just has less info now. I've updated the question again with what's printed in the Messages buffer. – gjvatsalya Oct 14 at 15:16
  • Oh, I missed that this is error is in response to running a command, so --debug-init won't help. Try M-x toggle-debug-on-error before package-refresh-contents instead. – npostavs Oct 14 at 18:17

Your Answer

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

Browse other questions tagged or ask your own question.