bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#53885: Autoload package-installed-p


From: Augusto Stoffel
Subject: bug#53885: Autoload package-installed-p
Date: Wed, 09 Feb 2022 15:39:34 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux)

On Tue,  8 Feb 2022 at 23:39, Corwin Brust <corwin@bru.st> wrote:

> Corrected reproducer:
>
> (progn
>   (setq package-user-dir "~/elpa")
>   (setq package-archives
>     '(("MELPA" .
>     "https://melpa.org/packages/";)))
>   (unless (package-installed-p 'use-package)
>     (package-install 'use-package)))

By the way, there are two issues with this code snippet.  First, you
should call '(package-refresh-contents)' to make sure you have the
package list from MELPA.

Second, and more subtly, calling package install during init time
doesn't add the package to the list of selected packages, so
'use-package' would be subject to removal by 'package-autoremove'.  To
fix this, something like

    (add-hook 'after-init-hook
              (lambda () (package--update-selected-packages '(use-package) 
nil)))

is needed.

I think a more user-friendly 'package-ensure-installed' function is in
order here.  I believe the use-package package provides some
functionality for this, but there is no good built-in equivalent (which
is needed even by use-package users).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]