According to emacs.SE answer I am trying to make Emacs (version 25.0.92) autoload packages if they are not already installed on my computer. At my .emacs file now I have only:


(require 'package)

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

(setq my-package-list '(nyan-mode dired+))

(mapc #'package-install my-package-list)

But have an an error:

error: Package ‘auctex-’ is unavailable

What I am doing wrong?

  • 1
    You are missing a (package-refresh-contents) call. If you not installing packages interatively via M-x list-packages (which automatically updates your local database for all packages available on package-archives), you need to do this refresh manually. Mar 16 '16 at 21:05
  • I would also recommend using use-package it will install missing packages and their dependencies. It is really great!
    – Jules
    Mar 16 '16 at 22:08
  • 1
    I'd also recommend you don't remove the default gnu archive, like you do.
    – Stefan
    Mar 17 '16 at 13:29

As @JulesTamagnan said, you should not use setq as that will totally replace the default value of package-archives. You do not need to add Melpa if you are doing it only to install auctex. But if you want to add Melpa, use add-to-list as he suggested.

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

The second missing piece is the call to package-refresh-contents.

Here is what I have:

(require 'package)

;; Load emacs packages and activate them
;; This must come before configurations of installed packages.
;; Don't delete this line.
;; `package-initialize' call is required before any of the below
;; can happen


;; Auto install the required packages
;; https://github.com/bbatsov/prelude/blob/master/core/prelude-packages.el
;; http://toumorokoshi.github.io/emacs-from-scratch-part-2-package-management.html
(defvar modi/missing-packages '()
  "List populated at each startup that contains the list of packages that need
to be installed.")

(dolist (p my-packages)
  (when (not (package-installed-p p))
    (add-to-list 'modi/missing-packages p)))

(when modi/missing-packages
  (message "Emacs is now refreshing its package database...")
  ;; Install the missing packages
  (dolist (p modi/missing-packages)
    (message "Installing `%s' .." p)
    (package-install p))
  (setq modi/missing-packages '()))
  • If I got (at only first startup) some warnings like Warning (bytecomp): reference to free variable ‘nyan-animate-nyancat’ and Warning (bytecomp): assignment to free variable ‘nyan-animate-nyancat’ -- does it matter?
    – drobnbobn
    Mar 16 '16 at 21:50
  • @drobnbobn When you say "at only first startup", is that the startup when that package got installed? Or is it every time emacs starts up? If it is the latter, you should file a bug report for that package (e.g. open issue on its github) to have it fixed. Mar 16 '16 at 22:26
  • Only when that package got installed.
    – drobnbobn
    Mar 16 '16 at 22:32
  • @drobnbobn In that case it is fine. But the dev should still try to fix those if possible. Mar 16 '16 at 22:37

Auctex is not in the melpa package archive it is in the gnu package archive instead of

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


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

This will keep the gnu package repo in the list of package archives

  • Didn't help, same error.
    – drobnbobn
    Mar 16 '16 at 19:41
  • Did you restart your emacs session in between attempts?
    – Jules
    Mar 16 '16 at 19:43
  • Surely I restart Emacs after changing .emacs. Also I reinstalled Emacs and tried again. Same result.
    – drobnbobn
    Mar 16 '16 at 20:14
  • is the value of package-archives contain to ("gnu" . "http://elpa.gnu.org/packages/"). If it does then I am not quite sure what to tell you, and I'll delete my answer. Sorry man
    – Jules
    Mar 16 '16 at 20:26
  • 2
    @JulesTamagnan The new link for Melpa package archive is http://melpa.org/packages/ [Reference]. Mar 16 '16 at 21:14

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.