安装 Package 失败: Package is unavailable. Is the package name misspelled ?

我将 Spacemacs 下的 elpa/ 目录下的已经下载下来的 Package 删除之后,Spacemacs 启动过程中会报很多奇怪的错误,最后定位发现是每次启动的时候都有部分 Package 没有正常下载下来,而且 Spacemacs 会报下面的错误:

Found 35 new package(s) to install… → refreshing package archive: gnu… [1/1] → installing package: ac-ispell@auto-completion… [1/35] Package ac-ispell is unavailable. Is the package name misspelled?y → installing package: ace-pinyin@chinese… [2/35] Package ace-pinyin is unavailable. Is the package name misspelled? → installing package: anaconda-mode@python… [3/35] Package anaconda-mode is unavailable. Is the package name misspelled? → installing package: auto-complete@auto-completion… [4/35] Package auto-complete is unavailable. Is the package name misspelled? → installing package: auto-yasnippet@auto-completion… [5/35] Package auto-yasnippet is unavailable. Is the package name misspelled? → installing package: chinese-pyim@chinese… [6/35] Package chinese-pyim is unavailable. Is the package name misspelled? → installing package: company-anaconda@python… [7/35] Package company-anaconda is unavailable. Is the package name misspelled? → installing package: cython-mode@python… [8/35] Package cython-mode is unavailable. Is the package name misspelled? → installing package: find-by-pinyin-dired@chinese… [9/35] Package find-by-pinyin-dired is unavailable. Is the package name misspelled? → installing package: fuzzy@auto-completion… [10/35] Package fuzzy is unavailable. Is the package name misspelled? → installing package: gh-md@markdown… [11/35] Package gh-md is unavailable. Is the package name misspelled? → installing package: gnuplot@org… [12/35] Package gnuplot is unavailable. Is the package name misspelled? → installing package: helm-c-yasnippet@auto-completion… [13/35] Package helm-c-yasnippet is unavailable. Is the package name misspelled? → installing package: helm-company@auto-completion… [14/35] Package helm-company is unavailable. Is the package name misspelled? → installing package: helm-pydoc@python… [15/35] Package helm-pydoc is unavailable. Is the package name misspelled? → installing package: htmlize@org… [16/35] Package htmlize is unavailable. Is the package name misspelled? → installing package: hy-mode@python… [17/35] Package hy-mode is unavailable. Is the package name misspelled? → installing package: live-py-mode@python… [18/35] Package live-py-mode is unavailable. Is the package name misspelled? → installing package: markdown-mode@markdown… [19/35] Package markdown-mode is unavailable. Is the package name misspelled? → installing package: markdown-toc@markdown… [20/35] Package markdown-toc is unavailable. Is the package name misspelled? → installing package: mmm-mode@markdown… [21/35] Package mmm-mode is unavailable. Is the package name misspelled? → installing package: mwim@better-defaults… [22/35] Package mwim is unavailable. Is the package name misspelled? → installing package: org-download@org… [23/35] Package org-download is unavailable. Is the package name misspelled? → installing package: org-pomodoro@org… [24/35] Package org-pomodoro is unavailable. Is the package name misspelled? → installing package: org-present@org… [25/35] Package org-present is unavailable. Is the package name misspelled? → installing package: org-projectile@org… [26/35] Package org-projectile is unavailable. Is the package name misspelled? → installing package: pangu-spacing@chinese… [27/35] Package pangu-spacing is unavailable. Is the package name misspelled? → installing package: pip-requirements@python… [28/35] Package pip-requirements is unavailable. Is the package name misspelled? → installing package: py-isort@python… [29/35] Package py-isort is unavailable. Is the package name misspelled? → installing package: pyenv-mode@python… [30/35] Package pyenv-mode is unavailable. Is the package name misspelled? → installing package: pytest@python… [31/35] Package pytest is unavailable. Is the package name misspelled? → installing package: pyvenv@python… [32/35] Package pyvenv is unavailable. Is the package name misspelled? → installing package: unfill@better-defaults… [33/35] Package unfill is unavailable. Is the package name misspelled? → installing package: yapfify@python… [34/35] Package yapfify is unavailable. Is the package name misspelled? → installing package: youdao-dictionary@chinese… [35/35] Package youdao-dictionary is unavailable. Is the package name misspelled?

而且我已经设置 emacs china 提供的 elpa 源:

(defun dotspacemacs/user-init () (setq configuration-layer–elpa-archives '((“melpa-cn” . “http://elpa.emacs-china.org/melpa/”) (“org-cn” . “http://elpa.emacs-china.org/org/”) (“gnu-cn” . “http://elpa.emacs-china.org/gnu/”))) )

看了下没一个包被下载,基本可以确定是因为网络环境不好。

如果系统是windows 先考虑下https支持问题。

我已经排查了网络环境,应该是没有问题的。

经过分析我发现了问题出现的原因,就是在 .emacs.d/init.el 中出现了很多 (package-initialize),就类似下面的:

;; Added by Package.el. This must come before configurations of ;; installed packages. Don’t delete this line. If you don’t want it, ;; just comment it out by adding a semicolon to the start of the line. ;; You may delete these explanatory comments.

;; Added by Package.el. This must come before configurations of ;; installed packages. Don’t delete this line. If you don’t want it, ;; just comment it out by adding a semicolon to the start of the line. ;; You may delete these explanatory comments.

;; Added by Package.el. This must come before configurations of ;; installed packages. Don’t delete this line. If you don’t want it, ;; just comment it out by adding a semicolon to the start of the line. ;; You may delete these explanatory comments.

;; Added by Package.el. This must come before configurations of ;; installed packages. Don’t delete this line. If you don’t want it, ;; just comment it out by adding a semicolon to the start of the line. ;; You may delete these explanatory comments. (package-initialize)

(package-initialize)

(package-initialize)

(package-initialize)

我将这些 (package-initialize) 都删除掉后,发现就回复正常了,所有的 Package 都能正常安装上了

但是我又发现了另外一个问题: 就是每次打开 Emacs后,其就会在 .emacs.d/init.el 中自动插入 (package-initialize) , 而这就是出现上面 Package 加载失败的原因。 我现在还不清楚为什么会出现这种现象。

将spacemacs放到系统的home目录下可以解决。

我将 spacemacs 放在了 Home 目录之后确实不会出现自动插入 (package-initialize) 的现象。请问这是什么原因导致的?

因为我是在 Windows 下使用 Spacemacs ,而且不想直接将 Spacemacs 放在 Home 目录下,于是就按照 Windows下设置Emacs的HOME目录 中的第二种方法来进行配置。

有没有办法能够在使用上面的配置方式的情况下解决这个问题?

在系统HOME目录下的init.el最上面加: ;;; init.el — Spacemacs Initialization File ;; ;; Copyright (c) 2012-2017 Sylvain Benner & Contributors ;; ;; Author: Sylvain Benner [email protected] ;; URL: GitHub - syl20bnr/spacemacs: A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim! ;; ;; This file is not part of GNU Emacs. ;; ;;; License: GPLv3

;; Without this comment emacs25 adds (package-initialize) here ;; (package-initialize)

;; Increase gc-cons-threshold, depending on your system you may set it back to a ;; lower value in your dotfile (function `dotspacemacs/user-config’)

经过测试发现在 Home 目录下的 init.el 加上你给的那段注释之后,确实把问题给解决了。

而且经过测试发现实际能够解决问题的是因为添加了下面一句注释:

;; (package-initialize)

而且我也找到了 Spacemacs 的代码修改记录 Emacs25 requires (pacakge-initialize) to be in init.el

从提交记录看是 Emacs 25 要求在 init.el 中添加的,但是我没有找到相关的资料说明为何要这样做?

1 个赞

我也是删掉这些多余的就好了,好麻烦啊

windows emacs25.1,启动spacemacs,近10分钟。晕死了。

问题的表现是: spacemacs启动,长时间白板显示,下方显示正在写入D:/EDA-tools/emacs/emacs-25.1/init.el。

发现D:/EDA-tools/emacs/emacs-25.1/init.el里串着几十个(package-initialize),把spacemacs启动过程搞得几乎瘫痪。

解决方法:在文件C:\Users\Administrator\AppData\Roaming\.emacs.d\init.el里加入

;; (package-initialize)

这个帖子对我有用!:+1::+1::+1::+1::+1:

我在这里补充一点,如果是在 develop branch 的话,应该是不会碰到这个问题了(这个问题的 fix 已经在 develop branch 了),但是如果仍然出现上述问题,那么基本可以认为是网络的问题。

解决办法分下面三个步骤:

  1. 换个网络环境,
  2. 删除 .emacs.d/elpa/archives 文件夹,
  3. 启动 spacemacs。

在init.el加上仍然不行,有大量包不可用

还是不行啊,还是同样的问题

你不是emacs配置的目录的问题把。

我昨天遇到同样问题,参照 这个 issue 解决了。方法是打开配置文件(SPC f e d)找到 dotspacemacs-elpa-timeout 5 这一行改成 dotspacemacs-elpa-timeout 300 (或任何比较大的数),重启。不知道能不能帮到你。

1 个赞

我之前在windows上也遇到过这样的问题,后来发现主要是用了GNU的emacs,里面缺少了不少windows下需要的dll。
建议下载下面地址里针对windows 64位优化过的emacs,用这个优化版的emacs后就没出现不能下载packages的问题了

在mac os 下,因为我把配置都写在了.spacemacs 文件中,就把.emacs.d 目录删了重新clone 下来,全部重新安装插件就好了。

管用,靠这个方法解决了,谢谢你!