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.
-
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– syohexCommented Apr 3, 2015 at 2:39
-
company-mode is better.– CodyChanCommented Apr 3, 2015 at 9:07
-
Try `M-x list-packages'. See if you find auto-complete in there.– MalabarbaCommented Apr 6, 2015 at 17:45
-
@Malabarba, I tried. it's not in there– cityCommented Apr 7, 2015 at 2:28
-
@city How many entries are listed when you list-packages? Is it around dozens or thousands?– MalabarbaCommented Apr 7, 2015 at 7:31
2 Answers
The following has been tested to work on an emacs -Q
session:
- Launch
emacs -Q
- Add the below in the scratch buffer:
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
- Evaluate the buffer (
M-x eval-buffer
) - 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.
-
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.– cityCommented Apr 6, 2015 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) ? Commented Apr 6, 2015 at 18:27 -
I tried it again. it still didn't work. my emacs version GNU Emacs 24.3.1– cityCommented Apr 7, 2015 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
. Commented Apr 7, 2015 at 2:30 -
I just proved it's our company's permission problem. I set up a proxy. it works now. thanks.– cityCommented Apr 7, 2015 at 5:56
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.
-
package-refresh-contents
is likeyum update
and if i am not wrong, it caches the list of available packages on remote url.– SaravanaCommented Apr 3, 2015 at 4:10 -
-
-
1did you do
M-x eval-buffer
to ensure that the emacs load the new emacs file?– SaravanaCommented Apr 4, 2015 at 6:45 -
@city after adding those lines to your init file, you need to restart Emacs. Commented Apr 4, 2015 at 12:45