purcell / emacs.d

An Emacs configuration bundle with batteries included
BSD 2-Clause "Simplified" License
6.84k stars 2.05k forks source link

file-error: "https://elpa.gnu.org/packages/archive-contents" "Bad Request" #721

Closed tianywan closed 5 years ago

tianywan commented 5 years ago

This error was reported when I try to open emacs with options "-nw". And my operating system is RHEL 8.0:

Debugger entered--Lisp error: (file-error "https://elpa.gnu.org/packages/archive-contents" "Bad Request") signal(file-error ("https://elpa.gnu.org/packages/archive-contents" "Bad Request")) package--download-one-archive(("gnu" . "https://elpa.gnu.org/packages/") "archive-contents" nil)

tianywan commented 5 years ago

Some more information on this issue: Debugger entered--Lisp error: (file-error "https://elpa.gnu.org/packages/archive-contents" "Bad Request") signal(file-error ("https://elpa.gnu.org/packages/archive-contents" "Bad Request")) package--download-one-archive(("gnu" . "https://elpa.gnu.org/packages/") "archive-contents" nil) package--download-and-read-archives(nil) package-refresh-contents() (if no-refresh (error "No version of %s >= %S is available" package min-version) (package-refresh-contents) (require-package package min-$ (if (cl-find-if (function (lambda (v) (version-list-<= min-version v))) versions) (package-install package) (if no-refresh (error "No ver$ (let ((known (cdr (assoc package package-archive-contents))) (versions (mapcar (function package-desc-version) known))) (if (cl-find-if $ (or (package-installed-p package min-version) (let ((known (cdr (assoc package package-archive-contents))) (versions (mapcar (function p$ (closure (t) (package &optional min-version no-refresh) "Install given PACKAGE, optionally requiring MIN-VERSION.\nIf NO-REFRESH is non-n$ apply((closure (t) (package &optional min-version no-refresh) "Install given PACKAGE, optionally requiring MIN-VERSION.\nIf NO-REFRESH is$ (let ((available (apply oldfun package args))) (prog1 available (if (and available (boundp 'package-selected-packages)) (progn (add-to-li$ sanityinc/note-selected-package((closure (t) (package &optional min-version no-refresh) "Install given PACKAGE, optionally requiring MIN-$ apply(sanityinc/note-selected-package (closure (t) (package &optional min-version no-refresh) "Install given PACKAGE, optionally requirin$

tianywan commented 5 years ago

I thought it was because my ip address was blocked by https://elpa.gnu.org or firewall as I could access the file by my browser.

purcell commented 5 years ago

Either ELPA is down or your Emacs doesn't support HTTPS.

tianywan commented 5 years ago

The version of my emacs is 26.1 and I install it from the yum source based on os dvd. Maybe I missed some required libraries? As I can access the website https://elpa.gnu.org/archive-contents, the elpa server should be working properly.

purcell commented 5 years ago

As I can access the website https://elpa.gnu.org/archive-contents, the elpa server should be working properly.

I agree, the error is probably with your Emacs not supporting SSL, or perhaps you have out-of-date root certificates installed. I can't really help debug your installation, sorry. PS. to test URLs from inside Emacs, use M-x eww.

shashank2000 commented 5 years ago

This error was reported when I try to open emacs with options "-nw". And my operating system is RHEL 8.0:

Debugger entered--Lisp error: (file-error "https://elpa.gnu.org/packages/archive-contents" "Bad Request") signal(file-error ("https://elpa.gnu.org/packages/archive-contents" "Bad Request")) package--download-one-archive(("gnu" . "https://elpa.gnu.org/packages/") "archive-contents" nil)

Were you able to fix this @tianywan? I have the exact same issue, the emacs on my Mac was too old, so I installed it with brew and updated the symlinks. Now I have this problem.

purcell commented 5 years ago

Were you able to fix this @tianywan? I have the exact same issue, the emacs on my Mac was too old, so I installed it with brew and updated the symlinks. Now I have this problem.

First, can you open something like https://duckduckgo.com in eww? If so, then TLS/SSL is basically working, and the problem might be with ELPA's certificate chains or your certificate store. If you haven't already, update your Homebrew openssl package.

Also, if you run M-: (gnutls-available-p), you'll get some info about the state of SSL support in your Emacs. For example, I see the following on my Mac with Emacs 26.2:

(ClientHello\ Padding Key\ Share Post\ Handshake\ Auth PSK\ Key\ Exchange\ Modes Cookie Supported\ Versions Early\ Data Pre\ Shared\ Key Session\ Ticket Record\ Size\ Limit Extended\ Master\ Secret Encrypt-then-MAC ClientHello\ Padding Server\ Certificate\ Type Client\ Certificate\ Type ALPN SRTP Signature\ Algorithms SRP Supported\ EC\ Point\ Formats Supported\ Groups OCSP\ Status\ Request Maximum\ Record\ Size Server\ Name\ Indication macs AEAD-ciphers ciphers digests gnutls3 gnutls)
tianywan commented 5 years ago

Sorry for my later reply. As this issue has been closed, I cannot see your question metioned me. @shashank2000. And thanks for Purcell's reply @purcell .

I fix this problem by removing https in the file ".emacs.d/lisp/init-elpa.el": Firstly, open the file and modify line 20 and line 29 as follows:

line 18: (let* ((no-ssl (and (memq system-type '(windows-nt ms-dos)) line 19: (not (gnutls-available-p)))) line 20: (proto (if no-ssl "http" "https"))) -->new line 20: (proto (if no-ssl "http" "http"))) ... line 28: ;; Force SSL for GNU ELPA line 29: (setcdr (assoc "gnu" package-archives) "https://elpa.gnu.org/packages/")))) --> new line 29: (setcdr (assoc "gnu" package-archives) "http://elpa.gnu.org/packages/"))))

Then when emacs finished downloading packages from elpa, I changed it back.

tianywan commented 5 years ago

My emacs can work properly now. It cannot access https://duckduckgo.com or https://elpa.gnu.org, but it can access something like https://www.baidu.com! What a funny finding! I may be blocked by the government's great firewall from accessing foreign websites with https! @purcell

shashank2000 commented 5 years ago

Awesome, it all works now thanks @purcell and @tianywan

purcell commented 5 years ago

I may be blocked by the government's great firewall from accessing foreign websites with https

Yes, that's almost certainly what's happening.

jcguu95 commented 5 years ago

I (currently in the States) had similar situation ("GNU" "bad request") and solved my problem by following the solution given in the issue: https://github.com/syl20bnr/spacemacs/issues/12535