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:
- 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.
- Set
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
as suggested here. - Set
(setq package-check-signature nil)
as suggested here. - 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)
emacs --debug-init
? Is there any text in the*Messages*
buffer?"NORMAL:-VERS-TLS1.3"
, try removing that setting (and it shouldn't be needed in Emacs 26.3 regardless).(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.--debug-init
won't help. TryM-x toggle-debug-on-error
beforepackage-refresh-contents
instead.