错误:package.el尚未初始化 我正在组织我的 .Emacs 文件,以便更好地跟踪我正在添加的所有内容。

错误:package.el尚未初始化 我正在组织我的 .Emacs 文件,以便更好地跟踪我正在添加的所有内容。,emacs,elisp,Emacs,Elisp,在这样做的过程中,我遇到了标题中描述的错误,我不确定确切的原因 这是我的.emacs文件:(所载评论仅供我自己参考) 运行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

在这样做的过程中,我遇到了标题中描述的错误,我不确定确切的原因

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

运行
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(#<buffer  *load*> 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()

所以我不确定我在哪里出错。。。有什么帮助吗?

在调用
软件包刷新和安装之前,您需要调用
软件包初始化
软件包初始化

不是初始化我们刚刚安装的软件包的全部目的吗?@ElectricCoffee除其他外,
软件包初始化
填充了已安装软件包的列表,因此,显然需要在
package-installed-p
之前调用它。
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(#<buffer  *load*> 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()
(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))))