Search code examples
emacsmelpa

Can't install some melpa packages in emacs


I'm just trying out emacs (coming from vim).

$  emacs --version
GNU Emacs 27.2
Copyright (C) 2021 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

$ cat ~/.emacs.d/init.el
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired.  See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

I've run M-x package-refresh-contents multiple times but still, many packages that I'd like to install aren't listed. For example, go-mode

trying to install go-mode

Any idea where I've messed up? Thanks!

EDIT

I just tried out spacemacs, and the packages I want show up in the list...


Solution

  • As explained in the comments, the behavior you got is just a feature of package.el (not a bug :)

    Namely, after installing a MELPA package with M-x package-install RET …, this package is not proposed anymore for installation.

    To check whether a package has indeed been installed, you can either:

    • Type M-x package-list-packages RET (RET = the Return key),
      and search for your package name: C-s go-mode C-s C-s … (C-s = Ctrl+S).
    • Or just run ls ~/.emacs.d/elpa/ to see if there's a go-mode-YYYYMMDD.* directory.

    Side notes

    It may be useful to upgrade all installed MELPA packages from time to time, by typing:

    • M-x package-list-packages RET
    • r (refresh the package list)
    • U (mark Upgradable packages)
    • x (execute the installs and deletions)

    Also, beyond the builtin Emacs package manager, you may be interested in the use-package tool:

    • to help organizing one's ~/.emacs file in a declarative way,
    • and installing packages automatically (namely, without needing to type M-x package-install by hand) while customizing them;

    → as an example of use, you could take a look at this Gist of mine to help installing Magit.