3

I am starting to build up a .emacs file to be used as a development environment within Docker containers. I get this error when starting emacs-nox in a Docker container.

Error (use-package): Failed to install magit: Package `magit-' is unavailable
Error (use-package): Cannot load magit

Here is the contents of my .emacs:

;; require package
(require 'package)
    
;; add melpa stable
(add-to-list 'package-archives
        '("melpa-stable" . "https://stable.melpa.org/packages/"))
    
;; add melpa
(add-to-list 'package-archives
        '("melpa" . "http://melpa.milkbox.net/packages/"))
    
;; Initialise packages
(package-initialize)
    
;; get latest package information
(package-refresh-contents)
    
;; add use package
;; so packages can automatically be installed
;; required for reuse across computer or docker containers
(package-install 'use-package)
    
;; add magit for git
(use-package magit
  :ensure t
    :pin melpa-stable)
7
  • Which emacs version are you using?
    – Kaligule
    Commented Mar 6, 2018 at 7:54
  • M-x version: "GNU Emacs 24.5.1 (x86_64-pc-linux-gnu) of 2017-09-12 on hullmann, modified by Debian" Commented Mar 6, 2018 at 14:15
  • 4
    I've run into this issue before. Run M-x package-refresh-contents and try again? Commented Mar 6, 2018 at 16:28
  • @ChakravarthyRaghunandan that did not work for me. I did M-x package-refresh-contents and then M-x eval-region on (use-package magit :ensure t :pin melpa-stable). I get the same error message. Commented Mar 6, 2018 at 17:39
  • Tried install the magit using M-x package-install RET magit ? Commented Mar 6, 2018 at 18:05

1 Answer 1

2

Thanks to the help of @ChakravarthyRaghunandan and @Kaligule and rereading the Melpa getting started I have been able to use use-package to install magit in a docker container in emacs-nox. The dockerfile starts with FROM debian:stable.

At Melpa - Getting Started, it says:

There are some problems using the https location with Emacs on Windows. There is currently no know easy fix for this. You can still use MELPA by using the non-SSL location by replacing https with http.

So I tried using http instead of https in the Melpa URLs.

(add-to-list 'package-archives
        '("melpa-stable" . "http://stable.melpa.org/packages/"))
    
(add-to-list 'package-archives
        '("melpa" . "http://melpa.org/packages/"))

That got it working.

4
  • 1
    I think an answer that uses https would be a better answer. Commented Mar 7, 2018 at 16:27
  • I am on Debian with emacs 27.1 and using http instead of https fixed my error of the same type when trying to install the package zetteldeft.
    – ning
    Commented Sep 2, 2020 at 2:02
  • just ran into this on a mac with same version of emacs and http:// worked for me also. Sigh.
    – sjatkins
    Commented Jan 21, 2021 at 22:08
  • trouble with http is that it doesn't solve issues with other lower level packages that have explicit https melpa get breaking with a 443 problem.
    – sjatkins
    Commented Jan 21, 2021 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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