Emacs package-install inserting extra dash?

对着背影说爱祢 提交于 2019-12-09 17:09:31

问题


I'm trying to have all of my dependencies install automatically for a new Emacs install. When I put the snippet below in my .emacs I keep getting: Package `smex-' is unavailable.

I was wondering if this is expected functionality? The Emacs starter-kit did something similar which I remember working before. Using Emacs 24.3.

(when (not package-archive-contents)
  (package-refresh-contents))

(defvar my-packages
  '(smex))

(dolist (p my-packages)
  (let ((s (symbol-name p)))
    (when (not (package-installed-p s))
      (package-install s))))

EDIT

Apparently this was caused by a bug or something. I was able to get it to work now in latest Emacs 24.3.1. Apparently they've also changed it so that package names should be symbols.

(package-initialize)

(when (not package-archive-contents)
  (package-refresh-contents))

(defvar my-packages
  '(list of packages))

(dolist (p my-packages)
  (when (not (package-installed-p p))
    (package-install p)))

回答1:


See package-compute-transaction:

(error "Package `%s-%s' is unavailable"
       (symbol-name next-pkg)
       (package-version-join next-version))



回答2:


I encountered this issue when I was using

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

after calling (package-initialize). If I execute

(setq package-archives '(("melpa" . "http://melpa.milkbox.net/packages/")
                         ("gnu" . "http://elpa.gnu.org/packages/")))

before (package-initialize), then the automated installation logic is able to install missing packages.



来源:https://stackoverflow.com/questions/19802757/emacs-package-install-inserting-extra-dash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!