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.

Warning (initialization): An error occurred while loading `/root/.emacs':

error: Package `use-package-' is unavailable

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)

;; add use package
(package-install 'use-package)
4

This particular error happens if Emacs failed looking up the latest version of a package, like if there's no package-archives file containing that information. Before installing packages, make sure to run M-x package-refresh-contents so that there is one. Alternatively, use M-x package-list-packages for installing packages, that ensures that the package-archives files are up to date.

  • This helped me get it working. I added (package-refresh-contents) to my .emacs file after (package-initialize) and before (package-install 'use-package). – learningemacs Mar 5 '18 at 21:17
  • Comments risk being deleted at any time. Consider moving your comment to an answer. – Drew Mar 5 '18 at 21:55
1

I am adding this answer as suggested by @Drew.

I appreciate the answer from @wasamasa which allowed me to get this working in my .emacs file.

Here is how I modified my .emacs file.

(package-initialize)

(package-refresh-contents)

(package-install 'use-package)

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.