3

When I am trying to do M-x package-refresh-contents I get Contacting host: elpa.gnu.org:80 stuck until I do C-g. I tried to install a package and it didn't work through M-x package-install *package_name* and it didn't work, so I started to search for a solution. I can't find the exact command I ran, but it was related to TLS and something with the word "Normal" IIRC. After doing so, my connection to repositories stopped working. I checked and changed many times my package-list, this is my current init.el code snippet related to links to melpa etc:

(setq package-archives                                                                                                                                                                                     
      '(("gnu" . "http://elpa.gnu.org/packages/")                                                                                                                                                          
        ("marmalade" . "http://marmalade-repo.org/packages/")                                                                                                                                              
        ("melpa" . "http://melpa.org/packages/"))) 

I also tested HTTPS connections, it works through eww and opens elpa.gnu link, giving me a list of packages, melpa.org site also works, but marmalade-repo is stuck in Loading http://marmalade-repo.org/packages/... . Not sure how to fix the emacs now, I also upgraded from the 26 version to 27, it didn't work. Currently using a workaround via using "Straight" package installation, but I want to try to understand what is wrong and how to fix it.

Jermog
  • 71
  • 4
  • 1
    I believe you want `https` for *both* `gnu` and `melpa`, and furthermore that `marmalade` may no longer be active (I didn't think it was still running, and while the domain is valid, it seemingly doesn't have a current certificate). You would rarely want to prefer `http` when `https` was supported. – phils Jun 16 '21 at 09:03
  • Yeah, need to add the parenthesis in my first post, it's in place in my init.el. It looks like maybe deleting marmalade and adding s to http fixed an issue, at least refresh now works, but need to check if packages can be successfully installed. – Jermog Jun 16 '21 at 10:40
  • Yes, it looks like melpa is indeed was the root of the problem (and possibly httpS). Thank you. – Jermog Jun 16 '21 at 10:46

3 Answers3

3

This worked for me. Thank-you. Specifically, I added the line (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") to my init.el. Actually a better way to set variables is with this line: (custom-set-variables '(gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))

I already had https for all my package archives, but apparently I was not using TLS1.3. So, when I would try to M-x package-refresh-contents, or simply U to upgrade, I was getting this error message:

Error retrieving: https://elpa.gnu.org/packages/archive-contents \ 
(error connection-failed "connect" :host "elpa.gnu.org" :service 443)

Anyway, adding that line to my init.el fixed the problem.

Zintis
  • 31
  • 5
1

I found I also needed the below:

gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"

Edit: I have since lost the site that I have found this. When I would try and issue a package-list-packages command it would hang and eventually time out. The person indicated that the packages site now requires TLS 1.3 and to add that line. Since then when I update my package list it does not hang.

I believe I found it here: https://stackoverflow.com/questions/55084969/emacs-listing-packages-error-in-process-sentinel

JonF
  • 11
  • 3
  • You mean I need to M-x it as S expression or to add it to init.el? – Jermog Jun 16 '21 at 10:36
  • I added it in init.el as: (custom-set-variables '(gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") ) – JonF Jun 16 '21 at 10:54
  • I have a feeling this was the expression I used initially, which caused issues in the first place. Maybe, using it caused problems with Marmelade. – Jermog Jun 16 '21 at 11:03
  • 1
    You also needed this to do what exactly? Please expand your answer to explain what goes wrong without this. – NickD Jun 16 '21 at 17:49
1

I can't mark a comment as an answer, so I will copy the comment of phils to mark it as a solution.

"I believe you want https for both gnu and melpa, and furthermore that marmalade may no longer be active (I didn't think it was still running, and while the domain is valid, it seemingly doesn't have a current certificate). You would rarely want to prefer http when https was supported."

The working configuration is therefore:

(setq package-archives                                                                                                                                                                                     
      '(("gnu" . "https://elpa.gnu.org/packages/")                                                                                                                                                          
        ("melpa" . "https://melpa.org/packages/"))) 
phils
  • 48,657
  • 3
  • 76
  • 115
Jermog
  • 71
  • 4