emacs 22.1 elpa error

When I installed emacs24.5 on osx it broke my .emacs.d/elpa directory.

this is the error I get when emacs loads:

"Cannot open load file", "/Users/xxxx/.emacs.d/elpa/archives/-pkg"

here is my emacs version:

GNU Emacs 22.1.1
Copyright (C) 2007 Free Software Foundation, Inc.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

here is my emacs --debug-int output:

Debugger entered--Lisp error: (file-error "Cannot open load file" "/Users/codymallery/.emacs.d/elpa/archives/-pkg")
  load("/Users/codymallery/.emacs.d/elpa/archives/-pkg" nil t)
  (if (file-directory-p pkg-dir) (load (concat pkg-dir ... "-pkg") nil t))
  (let ((pkg-dir ...)) (if (file-directory-p pkg-dir) (load ... nil t)))
  package-load-descriptor("/Users/codymallery/.emacs.d/elpa/" "archives")
  (lambda (name) (package-load-descriptor dir name))("archives")
  mapc((lambda (name) (package-load-descriptor dir name)) ("archive-contents" "archive-contents~" "archives" "builtin-package$
  (if (file-directory-p dir) (mapc (lambda ... ...) (directory-files dir nil "^[^.]")))
  (lambda (dir) (if (file-directory-p dir) (mapc ... ...)))("/Users/codymallery/.emacs.d/elpa/")
  mapc((lambda (dir) (if (file-directory-p dir) (mapc ... ...))) ("/Users/codymallery/.emacs.d/elpa/" "/usr/share/emacs/site-$
  (progn (package-initialize))
  (if (load (expand-file-name "~/.emacs.d/elpa/package.el")) (progn (package-initialize)))
  (when (load (expand-file-name "~/.emacs.d/elpa/package.el")) (package-initialize))
  eval-buffer(#<buffer  *load*> nil "/Users/codymallery/.emacs" nil t)  ; Reading at buffer position 866
  load-with-code-conversion("/Users/codymallery/.emacs" "/Users/codymallery/.emacs" t t)
  load("~/.emacs" t t)
  #[nil "^H\205\276^@   \306=\203^Q^@\307^H\310Q\202A^@ \311=\2033^@\312\307\313\314#\203#^@\315\202A^@\312\307\313\316#\203/$

here is my .emacs.d/elpa directory:

archive-contents    archives        builtin-packages~   package.el      paredit-20
archive-contents~   builtin-packages    caml-20141015.634   package.el~     tuareg-20150621.1418

here is the archives directory:

gnu     marmalade   melpa

here is my .emacs file:

;;; This was installed by package-install.el.                                                                                 
;;; This provides support for the package system and                                                                          
;;; interfacing with ELPA, the package archive.                                                                               
;;; Move this code earlier if you want to reference                                                                           
;;; packages in your .emacs.                                                                                                  
       (expand-file-name "~/.emacs.d/elpa/package.el"))

(defvar HOME (expand-file-name "~"))

;; ------
;; ------
(defvar GFORTH_EL (concat HOME "/.emacs.d/gforth.el"))

(cond ((file-readable-p GFORTH_EL)

  (load-library GFORTH_EL)

  (autoload 'forth-mode GFORTH_EL)

  (setq auto-mode-alist (cons '("\\.fs\\'" . forth-mode)

  (autoload 'forth-block-mode GFORTH_EL)

  (setq auto-mode-alist (cons '("\\.fb\\'" . forth-block-mode)

  (add-hook 'forth-mode-hook (function (lambda ()

    (setq forth-indent-level 4)

    (setq forth-minor-indent-level 2)

    (setq forth-hilight-level 3))))))

(require 'w3m-load)
(setq browse-url-browser-function 'w3m-goto-url)

;;rainbow parens support in lisp files
(load-file "~/.emacs.d/rainbow-delimiters.el")
(require 'rainbow-delimiters)
(add-hook 'lisp-mode-hook 'rainbow-delimiters-mode)
(add-hook 'emacs-lisp-mode-hook 'rainbow-delimiters-mode)

;;paredit support in slime repl
(add-hook 'slime-repl-mode-hook (lambda () (paredit-mode +1)))

;;paredit support for lisp files     
(autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t)
(add-hook 'emacs-lisp-mode-hook       #'enable-paredit-mode)
(add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode)
(add-hook 'ielm-mode-hook             #'enable-paredit-mode)
(add-hook 'lisp-mode-hook             #'enable-paredit-mode)
(add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode)
(add-hook 'scheme-mode-hook           #'enable-paredit-mode)

;;slime support
(setq inferior-lisp-program "/usr/local/bin/sbcl" --noinform)
(setq slime-backend "/usr/local/bin/lisp/slime/swank-loader.lisp")
(add-to-list 'load-path "/usr/local/bin/lisp/slime/")
(require 'slime)
(load-file "/usr/local/bin/lisp/slime/slime.el")
(slime-setup '(slime-fancy))

;; auto complete
(add-to-list 'load-path "/usr/local/bin/lisp/complete/")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/emacs.d//ac-dict")
(global-auto-complete-mode t)
(auto-complete-mode t)

;; add Lisp auto-complete-support
(add-to-list 'load-path "/usr/local/bin/lisp/complete/ac-slime/")
(require 'ac-slime)
(add-hook 'slime-mode-hook 'set-up-slime-ac)
(add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
(eval-after-load "auto-complete"
    '(add-to-list 'ac-modes 'slime-repl-mode))

;;AC everywhere fix
(define-globalized-minor-mode real-global-auto-complete-mode
    auto-complete-mode (lambda ()
                (if (not (minibufferp (current-buffer)))
                    (auto-complete-mode 1))))
    (real-global-auto-complete-mode t)

;; Use cperl-mode instead of the default perl-mode
(add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))

(add-hook 'cperl-mode-hook 'n-cperl-mode-hook t)
(defun n-cperl-mode-hook ()
  (setq cperl-indent-level 4)
  (setq cperl-continued-statement-offset 0)
  (setq cperl-extra-newline-before-brace t)
  (set-face-background 'cperl-array-face "wheat")
  (set-face-background 'cperl-hash-face "wheat")

As you can see I am loading the file but it thinks it's not there.

It's just so weird because I never edited the file it just stopped working once emacs 24 was ran once.

1 Answer 1


It looks like this issue will be fixed if you delete the archives directory inside ~/.emacs.d/elpa/. You may also have problems with the archive-contents and builtin-packages directories. Just to be sure, don't actually delete them, just move them somewhere else. (I woul also get rid of all those ~ backups).

That said, I'll strongly recommend you upgrade to Emacs 24 (preferably 24.5). Emacs 22 was a very long time ago, and you're probably also running a very old package.el.

  • +1 to the suggestion to upgrade past Emacs 22. That said, it's unfortunate that "it just stopped working once emacs 24 was ran once." That should not have happened, IMO.
    – Drew
    Jul 2, 2015 at 15:58
  • This code looks quite suspect: (load (concat pkg-dir ... "-pkg") nil t). OP: Is that code in your package.el version? Maybe the problem is the version of package.el? (package.el is not included with Emacs 22.)
    – Drew
    Jul 2, 2015 at 16:03
  • @Drew IIUC, he's using one of the initial versions of package.el (way before it was made part of emacs).
    – Malabarba
    Jul 2, 2015 at 16:09
  • in the end I upgraded to emacs 24.5 but package-refresh-contents hangs on contacting host melpa.org:80 and I have (setq package-archives '(("gnu" . "elpa.gnu.org/packages/") ("marmalade" . "marmalade-repo.org/packages/") ("melpa" . "melpa.org/packages/"))) set in emacs. I'll accept your answer and probably post another question.
    – Cody
    Jul 2, 2015 at 18:34
  • @Cody Firstly, did you remove that (load ... "~/.emacs.d/elpa/package.el") from your init file? Also, since you're coming from a very old version, I recommend moving your whole elpa/ directory somewhere else and reinstall your packages from the package menu.
    – Malabarba
    Jul 2, 2015 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.