I want to add C auto-completion at least so that I can use Emacs on a regular basis as my C editor. I am new to Emacs, and I had already it installed in my system, because it came with the OS (I think). It's version is 22.1.1.

I'm trying to follow the following tutorial:


To add auto-completion to Emacs, and we started by adding the following code to the ~/.emacs file:

; start package.el with emacs
(require 'package)
; add MELPA to repository list
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
; initialize package.el

But when I save the file ~/.emacs and start Emacs again, I get the following message:

An error has occurred while loading `/Users/cell/.emacs':

File error: Cannot open load file, package

To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the `--debug-init' option to view a complete error backtrace.

Loading find-func...done find-library-name: Can't find library package

I don't know anything about Lisp, but from my understanding the problem is that the package called 'package does not exist. Indeed if I try to search it with

M-x find-library

and then I type package, it tells me:

Can't find library package

According to this answer:


It might be that my Emacs does not have package. How can I solve this, and mostly, how can I add auto-completion to C programs?

Note: I would prefer to stick with this version of Emacs terminal since it came with the OS, apparently. I've also installed another Emacs using a .dmg file, but I would like to work on the terminal also (or mostly).

  • If you are on OSX I don't think Emacs would have come preinstalled (though I could be wrong). I also don't know if your issue is caused by having an older version - but your version is quite old. I know you don't want to update, but I think you will run into more issues than this if you do not. – elethan Mar 3 '16 at 20:49
  • 1
    @elethan OS X includes GNU Emacs 22, the last version released under GPL 2. – user227 Mar 3 '16 at 21:55
  • @lunaryorn thanks for the info! I was assuming that since it doesn't come pre-packaged with most Linux distributions that it wouldn't come packaged with OS X. – elethan Mar 3 '16 at 21:57

OS-X comes with emacs 22, which is several years out of date. One easy way to get a current emacs is by downloading from http://emacsformacosx.com/. This will give you package.

| improve this answer | |
  • Yes, this is exactly the one I installed (apart from the one I had already). The problem is that I would like to run Emacs also from the terminal, and the command emacs is by default connected to the Emacs which comes with the OS...I know I can add the new installed Emacs to the path, but is there a way to make this new one the default one? – user8802 Mar 3 '16 at 21:28
  • 3
    Adding the new emacs to the path should do the trick, just put it at the front. I've got this in my .bash_profile: export PATH=/Applications/Emacs.app/Contents/MacOS:$PATH – Jon Kåre Hellan Mar 3 '16 at 21:37
  • Yes, it did the trick, thanks! And to start it without the windowing system, I also add the following alias: alias="emacs -nw", if someone is interested. – user8802 Mar 3 '16 at 21:41
  • I have a question: does the dmg-installed Emacs also refers to the ~/.emacs before initialising or does it refer to its own initial-options launching file? – user8802 Mar 3 '16 at 21:45
  • The same ~/.emacs – Jon Kåre Hellan Mar 3 '16 at 21:48

Your Answer

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