30

while going through the emacs as a c/c++ editor , I came across the following lines of code to include in my ~/.emacs file, to connect to melpa archives for package installation

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

after saving these lines into emacs , when i started emacs it is showing me an wrong type argument: arrayp, nil in the minibuffer area

when i tried for $ emacs --debug -init , I got :

Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
  package--add-to-archive-contents(nil "melpa")
  package-read-archive-contents("melpa")
  package-read-all-archive-contents()
  package-initialize()
  eval-buffer(#<buffer  *load*> nil "/home/anupam/.emacs" nil t)  ; Reading at buffer position 905
  load-with-code-conversion("/home/anupam/.emacs" "/home/anupam/.emacs" t t)
  load("~/.emacs" t t)
  #[0 "\205\262�    \306=\203�\307\310Q\202;�   \311=\204�\307\312Q\202;�\313\307\314\315#\203*�\316\202;�\313\307\314\317#\203:�\320\nB\321\202;�\316\322\323\322\211#\210\322=\203a�\324\325\326\307\327Q!\"\323\322\211#\210\322=\203`�\210\203\243�\330!\331\232\203\243�\332!\211\333P\334!\203}�\211\202\210�\334!\203\207�\202\210�\314\262\203\241�\335\"\203\237�\336\337#\210\340\341!\210\266\f?\205\260�\314\323\342\322\211#)\262\207" [init-file-user system-type delayed-warnings-list user-init-file inhibit-default-init inhibit-startup-screen ms-dos "~" "/_emacs" windows-nt "/.emacs" directory-files nil "^\\.emacs\\(\\.elc?\\)?$" "~/.emacs" "^_emacs\\(\\.elc?\\)?$" (initialization "`_emacs' init file is deprecated, please use `.emacs'") "~/_emacs" t load expand-file-name "init" file-name-as-directory "/.emacs.d" file-name-extension "elc" file-name-sans-extension ".el" file-exists-p file-newer-than-file-p message "Warning: %s is newer than %s" sit-for 1 "default"] 7 "\n\n(fn)"]()
  command-line()
  normal-top-level()

I am new to emacs, can someone please tell me how can i resolve this?

41

I ran into this the other day. I think it was caused by an invalid package archive file. The immediate fix is to delete <user-emacs-directory>/elpa/archives/melpa/archive-contents; it will be rebuilt on the next package-initialize. Unfortunately, package.el is not very robust to this sort of failure.

  • you are right it worked for me about 12 hours, then suddenly this problem came out of nowhere.. besides many packages mentioned in the tutorial series are not in the standard elpa.gnu.org.. – lazarus Nov 3 '15 at 6:04
  • isn't there any other alternative to solve this problem? – lazarus Nov 3 '15 at 6:05
  • I think it's probably a bug in MELPA (combined with a lack of resilience in package.el), you might want to file an issue there. – shosti Nov 3 '15 at 17:25
  • Not sure if it is relevant, but the address for the repository has change: now it recommends: (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) – rvf0068 Nov 11 '15 at 2:18
  • I ran in the same problem after a package upgrade. The fix worked like a charm. Thanks. – rkachach Apr 27 '16 at 5:39
4

I had the same problem and applied the following fix. This worked for me:

  • Change the address for the melpa archive to: "http://melpa.org/packages"
  • Delete the ~/.emacs.d/elpa/archives/melpa/archive-contents file
  • Run package-initialize and package-refresh-contents.

I have a package-refresh-contents command in my .emacs file. This ensures that the packages are always up to date but it adds about two seconds to the boot time of emacs.

My package-related commands in .emacs look like this:

;; Package system
(require 'package)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
                         ("marmalade" . "https://marmalade-repo.org/packages/")
                         ("melpa" . "http://melpa.org/packages/")
                         ("user42" . "http://download.tuxfamily.org/user42/elpa/packages/")))
(package-initialize)

(package-refresh-contents)
(setq auto-install-packages
      '(color-theme bar-cursor htmlize flycheck flycheck-haskell
                    haskell-mode sml-mode rust-mode fsharp-mode nasm-mode go-mode
                    perl-mode web-mode )) ;;ffap-perl-module markdown-mode))
(dolist (pkg auto-install-packages)
  (unless (package-installed-p pkg)
    (package-install pkg)))
  • I am experiencing this problem quite often. I wonder if there is a way to automate the deleting of the file ~/.emacs.d/elpa/archives/melpa/archive-contents whenever this problem occurs. – Thorkil Værge Apr 12 '16 at 21:52
  • 1
    Do you mean alias rm_archive='rm -r <user-emacs-directory>/elpa/archives/melpa/archive-contents' in your ~/.bashrc file? – snd Jun 14 '16 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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