* lisp/emacs-lisp/package.el (package--save-selected-packages): Allow
setting 'package-selected-packages' to a nil value. (bug#65475)
(defun package--save-selected-packages (&optional value)
"Set and save `package-selected-packages' to VALUE."
- (when value
+ (when (or value after-init-time)
+ ;; It is valid to set it to nil, for example when the last package
+ ;; is uninstalled. But it shouldn't be done at init time, to
+ ;; avoid overwriting configurations that haven't yet been loaded.
(setq package-selected-packages value))
(if after-init-time
(customize-save-variable 'package-selected-packages package-selected-packages)