Description
It seems that the function exercism//install-required-packages
in tools/install-packages.el
assumes that if the variable package-archive-contents
is not nil, the variable package-archives
contains the gnu and melpa site information. This assumption does not hold in general.
For example, an emacs user has run (package-refresh-contents)
without explicitly setting package-archives
. In this case, package-archives
contains the "gnu" and "nongnu" sites but not the "melpa" site, so that package-archive-contents
is filled with the information downloaded from the "gnu" and "nongnu" sites. But two among the three required packages, mustache and string-inflection, are only avialble at the melpa site. So, running exercism//install-required-packages
will result in an error message, not being able to install mustache or string-inflection, unless both of them have been already installed.
The problem can be fixed easily. Intead of checking if package-archive-contents
is nil, we can directly check if the three required packages have been installed. The resulting code loos like:
(defun exercism//install-required-packages ()
(require 'package)
(package-initialize)
(let ((required-packages '(mustache ht string-inflection)))
(when (not (cl-every #'package-installed-p required-packages))
(add-to-list
'package-archives '("gnu" . "https://elpa.gnu.org/packages/")
t)
(add-to-list
'package-archives '("melpa" . "https://melpa.org/packages/")
t)
(package-refresh-contents)
(dolist (pkg required-packages)
(package-install pkg)))))
Does this look OK? If so, shall I submit a PR?