0

I recently switched from sublime text 3 to emacs so I still don't quite understand everything. When I launch emacs and run package-install, I can not look up packages from Melpa to install, e.g., projectile. Although once I have ran package-list-packages the list of available packages is refreshed and the packages from Melpa are indexed. Then if I run package-install again, I can find more packages including the ones from Melpa (hence projectile). I have this in my .emacs settings file:

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

emacs --version returns:

GNU Emacs 25.2.2
Copyright (C) 2017 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.

I am running this on Ubuntu 18.04.3 LTS.

enter image description here

0

Until package-refresh-contents is called, Emacs doesn't know about packages in package archives. Its documentation:

Download descriptions of all configured ELPA packages.

For each archive configured in the variable ‘package-archives’, inform Emacs about the latest versions of all packages it offers, and make them available for download.

Optional argument ASYNC specifies whether to perform the downloads in the background.

So, if you want to load the list of available packages, make that call in your init file. You could even give it the async argument, so Emacs doesn't block until it comes back:

(package-refresh-contents t)

  • Is it possible to call package-refresh-contents only when package-install is called, like it is called when you list packages. That way I won't be downloading stuff I don't need unless I am trying to install something in which case I'll have all the available packages indexed. – scribe Sep 20 at 22:26
  • Doing it asynchronously at least means Emacs isn't waiting for it to finish. You could probably add it as advice around package-install. – zck Sep 21 at 22:44

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.