10

I am trying to set up emacs (on cygwin / Win10) to handle JSON.

I started with joshwnj/json-mode and was stoked to discover that emacs will now install its own dependencies from online repos. Fab stuff.

I can run M-x package-install but I notice it logs the message:

Contacting host: elpa.gnu.org:80
Failed to download ‘gnu’ archive.

And when I type in json-mode, emacs says there's no match. Is this a connection problem? Should I see an HTTP error somewhere?

joshwnj/json-mode says I need the MELPA repository set up.

According to this documentation for MELPA I need to identify if I'm using package.el (which looks good) and work out if the given lisp code is in place.

Is there a command I can run in emacs to tell me if this code is in place?

Trying to following on and ignoring that issue, I tried M-x package-list-packages and got the following error:

You can run the command ‘package-list-packages’ with M-x pa-l- RET
Waiting for refresh to finish...
Package refresh done
No packages to upgrade.
error in process sentinel: Error retrieving: http://elpa.gnu.org/packages/archive-contents (error connection-failed "failed with code 10060
" :host "elpa.gnu.org" :service 80)
error in process sentinel: Error retrieving: http://elpa.gnu.org/packages/archive-contents (error connection-failed "failed with code 10060
" :host "elpa.gnu.org" :service 80)

Is the sentinel process critical? Did the package refresh work?

What should I try next?

Adam
  • 241
  • 2
  • 7

2 Answers2

7

It appears that

(custom-set-variables
 '(gnutls-algorithm-priority "normal:-vers-tls1.3"))

fixes the problem.

Cf. https://stackoverflow.com/a/60638601/850781

sds
  • 5,928
  • 20
  • 39
  • 1
    How did you find this out? – mtd Feb 16 '21 at 17:53
  • 1
    @mtd: [`emacs-devel` mailing list](https://lists.gnu.org/mailman/listinfo/emacs-devel) – sds Feb 16 '21 at 17:55
  • 1
    thanks. FWIW, I am still seeing the reported symptom, and your fix addressing it, using emacs 27.1 (` emacs-27.1-2.fc33.x86_64`). – mtd Feb 16 '21 at 22:07
  • fwiw it fixed it for me on "GNU Emacs 27.2 (build 1, x86_64-apple-darwin21.1.0, Carbon Version 165 AppKit 2113) of 2021-12-11" – algal Jan 21 '22 at 00:32
2

Have you tried to set the package-archives variable in your configuration file?

I have added the following lines to my configuration to get packages from elpa, marmalade, and melpa:

(package-initialize)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/") t)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
colelemonz
  • 276
  • 2
  • 4
  • 1
    Although I haven't checked, I assume I already have those set by default because of the error. If I do `M-x package-refresh-contents` I get `Contacting host: elpa.gnu.org:80 Failed to download ‘gnu’ archive.` – Adam Jan 08 '18 at 13:05
  • The ELPA repository may be set up by default, but the MELPA (which you said that you needed) and Maramalde repositories won't be set up by default. – colelemonz Jan 08 '18 at 23:59
  • 2
    Looking into the issue further, are you by chance behind a firewall? That may be blocking your connection to ELPA. Furthermore, have you installed [GnuTLS](https://www.gnutls.org/)? If you are on Windows, i refer you to [here](https://www.reddit.com/r/emacs/comments/5g4jdi/having_issues_with_downloading_packages_and/dapwauk/?st=jc6ve7ak&sh=95ddbe15), and this may also [be useful](https://emacs.stackexchange.com/questions/27202/how-do-i-install-gnutls-for-emacs-25-1-on-windows). – colelemonz Jan 09 '18 at 00:02
  • I run emacs under cygwin and cygwin has gnutls - is that not enough? – Adam Jan 09 '18 at 13:50
  • Not sure, I don't have access to a Windows box to test it. – colelemonz Jan 09 '18 at 19:41