错误:package.el尚未初始化

 ww心海星空 发布于 2022-12-19 07:02

我正在组织我的.emacs文件以更好地跟踪我正在添加的所有内容.

这样做我遇到了标题中描述的错误,我不确定为什么

这是我的.emacs文件:(评论的加载是我自己的参考)

;;;; Emacs config file

;; convenience function for loading multiple libs in a single call
(defun load-libs (&rest libs) 
  (dolist (lib libs) 
    (load-library lib)))

;; path to custom libraries as well as the libraries themselves
(add-to-list 'load-path "~/.emacs.d/lisp/")
(load-libs "convenience" "editor-behaviour")

;; Add support for the package manager
(require 'package)
;; Add various package archives
(add-to-list 'package-archives
         '("marmalade" . "http://marmalade-repo.org/packages/")
         '("melpa" . "http://melpa.milkbox.net/packages/"))

;; Installs packages if they aren't already
(package-refresh-and-install        ; from convenience.el
 'scala-mode2 'sbt-mode 'haskell-mode 'geiser 'auto-complete 'ac-geiser 'cider)

;; Initialise packages
(package-initialize)

;; libs dependent on the packages being initialized go here
(load-library "autocomplete-config")

;; Enable Haskell indentation
(custom-set-variables 
 '(haskell-mode-hook '(turn-on-haskell-indentation)))

跑步emacs .emacs --debug-init给我以下输出:

Debugger entered--Lisp error: (error "package.el is not yet initialized!")
  signal(error ("package.el is not yet initialized!"))
  error("package.el is not yet initialized!")
  package-installed-p(scala-mode2)
  (if (package-installed-p pkg) nil (package-refresh-contents) (package-install pkg))
  (while --dolist-tail-- (setq pkg (car --dolist-tail--)) (if (package-installed-p pkg) $
  (let ((--dolist-tail-- pkgs) pkg) (while --dolist-tail-- (setq pkg (car --dolist-tail-$
  package-refresh-and-install(scala-mode2 sbt-mode haskell-mode geiser auto-complete ac-$
  eval-buffer(# nil "/Users/ElectricCoffee/.emacs" nil t)  ; Reading at $
  load-with-code-conversion("/Users/ElectricCoffee/.emacs" "/Users/ElectricCoffee/.emacs$
  load("~/.emacs" t t)
  #[0 "^H\205\262^@     \306=\203^Q^@\307^H\310Q\202;^@ \311=\204^^^@\307^H\312Q\202;^@\$
  command-line()
  normal-top-level()

这表明(根据我的理解)它与之有关convenience.el,但所有这些都是这样的:

(defun package-refresh-and-install (&rest pkgs)
  "Utility function to refresh package contents and install several packages at once"
  (dolist (pkg pkgs)
    (unless (package-installed-p pkg)
      (package-refresh-contents)
      (package-install pkg))))

所以我不确定我在哪里犯错误...有什么帮助吗?

1 个回答
  • 你打电话package-initialize之前需要打电话package-refresh-and-install.

    2022-12-19 07:20 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有