2

I am trying to install package auto-complete. But when I typed M-x package-install [ret], then emacs showed "contacting host: elpa.gnu.org:80". After a while, it showed "Install package". Then I typed "auto-complete", it prompted "no match". Do I miss something here? thanks.

6
  • Do you set MELPA or MELPA stable repository to package-archives ? If not yet, please set. See Also ergoemacs.org/emacs/emacs_package_system.html
    – syohex
    Apr 3 '15 at 2:39
  • company-mode is better.
    – CodyChan
    Apr 3 '15 at 9:07
  • Try `M-x list-packages'. See if you find auto-complete in there.
    – Malabarba
    Apr 6 '15 at 17:45
  • @Malabarba, I tried. it's not in there
    – city
    Apr 7 '15 at 2:28
  • @city How many entries are listed when you list-packages? Is it around dozens or thousands?
    – Malabarba
    Apr 7 '15 at 7:31
5

The following has been tested to work on an emacs -Q session:

  1. Launch emacs -Q
  2. Add the below in the scratch buffer:
(require 'package)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.org/packages/") t)
  1. Evaluate the buffer (M-x eval-buffer)
  2. Do M-x package-install RET auto-complete RET

The package will install.

Note that step 4 will NOT work if you already have the package installed in the ~/.emacs.d/elpa/ folder. So to test this, either move the elpa/ folder to something like elpa.bkp/ before step 1 or do M-x list-packages (after step 3), find the auto-complete package in there, hit d to mark it for deletion and then x to execute the deletion. Then step 4 will work once again.

12
  • at step 3, I got "Symbol's value as variable is void: package-archives". and I deleted epla/ and restart emacs. It doesn't work. Maybe the reason is our company doesn't allow us connect the third party website directly. thanks anyway.
    – city
    Apr 6 '15 at 18:05
  • 1
    @city I added a require statement in step 2. Can you please try again? Also, what is your emacs version (M-x emacs-version) ? Apr 6 '15 at 18:27
  • I tried it again. it still didn't work. my emacs version GNU Emacs 24.3.1
    – city
    Apr 7 '15 at 2:16
  • I repeated those exact steps in an emacs -Q session on emacs 24.3 and they worked fine. What doesn't work? What errors/messages do you see in the messages buffer? You can quickly access that buffer using C-h e. Apr 7 '15 at 2:30
  • I just proved it's our company's permission problem. I set up a proxy. it works now. thanks.
    – city
    Apr 7 '15 at 5:56
3

You must add the urls for gnu, melpa, marmalade repositories in .emacs file

(setq package-archives 
  '(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.org/packages/")))

After doing this, run M-x package-refresh-contents and M-x auto-complete. It should work.

6
  • package-refresh-contents is like yum update and if i am not wrong, it caches the list of available packages on remote url.
    – Madhavan
    Apr 3 '15 at 4:10
  • I followed your instruction. it still prompted no match :(
    – city
    Apr 3 '15 at 18:07
  • and I run M-x list-packages, no auto-complete was in the list
    – city
    Apr 3 '15 at 18:15
  • 1
    did you do M-x eval-buffer to ensure that the emacs load the new emacs file?
    – Madhavan
    Apr 4 '15 at 6:45
  • @city after adding those lines to your init file, you need to restart Emacs.
    – Malabarba
    Apr 4 '15 at 12:45

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.