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)
learningemacs
  • 343
  • 1
  • 3
  • 11
  • Which emacs version are you using? – Kaligule Mar 06 '18 at 07:54
  • M-x version: "GNU Emacs 24.5.1 (x86_64-pc-linux-gnu) of 2017-09-12 on hullmann, modified by Debian" – learningemacs Mar 06 '18 at 14:15
  • 4
    I've run into this issue before. Run `M-x package-refresh-contents` and try again? – Chakravarthy Raghunandan Mar 06 '18 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. – learningemacs Mar 06 '18 at 17:39
  • Tried install the `magit` using `M-x package-install RET magit` ? – Chakravarthy Raghunandan Mar 06 '18 at 18:05
  • @ChakravarthyRaghunandan thanks for the suggestions. `M-x eval-region` on `(package-install 'magit)` gives this error `Package 'magit-' is unavailable`. `M-x package-install RET magit` gives a list of possible completions that does not include `magit` but has many magit-* suggestions. Doing `M-x package-list-packages` also does not list `magit` but does list many magit-* packages. – learningemacs Mar 06 '18 at 21:34
  • @learningemacs they both use the same packages list. Add melpa to your package list using this: `(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))` and restart emacs and try again – Chakravarthy Raghunandan Mar 07 '18 at 03:38

1 Answers1

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.

learningemacs
  • 343
  • 1
  • 3
  • 11
  • 1
    I think an answer that uses `https` would be a better answer. – learningemacs Mar 07 '18 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 Sep 02 '20 at 02:02
  • just ran into this on a mac with same version of emacs and http:// worked for me also. Sigh. – sjatkins Jan 21 '21 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 Jan 21 '21 at 22:32