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?

6
  • 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 5 '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 5 '20 at 19:21
  • @ Tyler: I'm sure there's no copy/paste error. – martinoidar Nov 5 '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 5 '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 5 '20 at 20:23
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...

2
  • 1
    See this: emacs.stackexchange.com/questions/61547/… - it is the same problem. – Ian Nov 9 '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. Personally, I decided to use AppImage version of Emacs 27.1 and this did the trick. – martinoidar Nov 9 '20 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.