0

I am working on Debian 10 with Emacs installed from official Debian repositories (ver 1:26.1+1-3.2) and using the following code I cannot connect to synchronize packages available on MELPA: Here's my init file:

(require 'package) 

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

(package-initialize)

(unless package-archive-contents
  (package-refresh-contents))

(setq my-package-list '(use-package))

(dolist (package my-package-list)
  (unless (package-installed-p package)
    (package-install package)))

    

Whatever I do, I keep obtaining:

 "Package 'use-package-' is unavailable" 

I checked ~/.emacs.d/elpa/archives and I have no melpa directory in it, only gnu and org.

On the other hand I can fetch melpa's repositories via:

 curl https://melpa.org/packages/archive-contents

I can also use melpa with the use of straight.el, for example via this code:

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))


(straight-use-package 'use-package)

But as far as I can see straight.el fetches MELPA repository on its own.

What is wrong with the original code? What can I do to track the problem?

  • Melpa redirects HTTP to HTTPS, thus if Emacs's url.el can't handle HTTPS, Melpa won't work. straight.el doesn't use any ELPA. ELPA is used by package.el, the builtin package manager, and straight.el is another package manager which does not need ELPA. – xuchunyang Nov 05 '20 at 19:14
  • The error you get suggests that you've passed a string "use-package", rather than a symbol (i.e., `'use-package`), the function `install-package`. However, your code looks correct, and it works as expected for me. Is it possible there's been a copy/paste error somewhere? – Tyler Nov 05 '20 at 19:21
  • @ Tyler: I'm sure there's no copy/paste error. – martinoidar Nov 05 '20 at 20:22
  • @xuchunyang: Do you suggest that first I should do something about url.el before going to package initialization and refresh? Simple changing "http ://melpa.org/packages/" to "https ://melpa.org/packages/" does not work. – martinoidar Nov 05 '20 at 20:22
  • @BothOfYou :): When I start emacs with the original version of init.el, I obtain the following message: Buffer " *http melpa.org:443*" has a running process; kill it? (yes or no) – martinoidar Nov 05 '20 at 20:23
  • You need to figure what's going wrong, that is, why Emacs can't fetch https://melpa.org/packages/archive-contents, the website works fine as your curl command suggests, ELPA is simply a HTTP service, if curl works, then Melpa works, if package.el doesn't work, blame Emacs, not Melpa. Don't forget Emacs's builtin HTTP client, url.el, is not very robust, especially for HTTPS. – xuchunyang Nov 06 '20 at 03:45

1 Answers1

0

OK. It's not really an answer to my question. It's only a workaround that I found here as a workaround to a similar problem (maybe even the same?) and it works for me. So I just replaced

("melpa" . "http://melpa.org/packages/")

with

("melpa" . "https://raw.githubusercontent.com/d12frosted/elpa-mirror/master/melpa/")

and now init file is processed and use-package is installed.

But still, anyone who knows the solution to the problem is wanted... alive...

  • 1
    See this: https://emacs.stackexchange.com/questions/61547/emacs-cant-connect-to-gnu-archive - it is the same problem. – Ian Nov 09 '20 at 14:21
  • Yes, You're right. A few moments ago I found independently the very same reason of undesirable working of Emacs and I was just about to write about it... The description of the problem and several ways of dealing with it can be found [here](https://stackoverflow.com/a/58236306/13215783). Personally, I decided to use [AppImage version of Emacs 27.1](https://appimage.github.io/Emacs/) and this did the trick. – martinoidar Nov 09 '20 at 16:50