GNU bug report logs -
#53885
Autoload package-installed-p
Previous Next
Reported by: Corwin Brust <corwin <at> bru.st>
Date: Tue, 8 Feb 2022 23:56:02 UTC
Severity: normal
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 53885 in the body.
You can then email your comments to 53885 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Tue, 08 Feb 2022 23:56:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Corwin Brust <corwin <at> bru.st>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 08 Feb 2022 23:56:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Commentary:
If the change is accpted, please consider fixing this for emacs-28.
The reproducer represents a common use-case, e.g. see bug #31397.
Moverover, it is a one-line change unlikely to affect anything aside
this and similar use-cases.
I will submit a patch as soon as I have a BugID from the tracker.
Although this change is rather trivial I need to practice this
process.
Reproducer:
NOTE: Make sure you have a folder beneth your home directory called
"elpa" and that it is empty.
Launch emacs -Q
Insert and evaluate:
(progn
(setq package-user-dir "~/elpa")
(setq package-archives
'(("MELPA" .
"https://melpa.org/packages/")))
(require 'package)
(unless (package-installed-p 'use-package)
(package-install 'use-package)))
Expected result:
Packages are installed under ~/elpa
Actual Result:
Debugger entered--Lisp error: (void-function package-installed-p)
(package-installed-p 'use-package)
(if (package-installed-p 'use-package) nil (package-install 'use-package))
(progn (if (package-installed-p 'use-package) nil (package-install
'use-package)))
elisp--eval-last-sexp(nil)
eval-last-sexp(nil)
funcall-interactively(eval-last-sexp nil)
command-execute(eval-last-sexp)
Work-around:
(progn
(setq package-user-dir "~/elpa")
(setq package-archives
'(("MELPA" .
"https://melpa.org/packages/")))
(require 'package) ;; workaround
(unless (package-installed-p 'use-package)
(package-install 'use-package)))
--
In GNU Emacs 28.0.91 (build 6, x86_64-w64-mingw32)
of 2022-02-05 built on AVALON
Repository revision: 821c240075e3b850a61207d18d520126292421ce
Repository branch: emacs-28-nt-dist-build
Windowing system distributor 'Microsoft Corp.', version 10.0.19043
System Description: Microsoft Windows 10 Home (v10.0.2009.19043.1503)
Configured using:
'configure --with-json --without-dbus --with-native-compilation
--without-compress-install CFLAGS=-O2'
Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
XPM ZLIB
Important settings:
value of $LANG: ENU
locale-coding-system: cp1252
Major mode: Lisp Interaction
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
indent-tabs-mode: t
transient-mark-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search seq byte-opt
gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils help-fns radix-tree cl-print
debug backtrace help-mode find-func time-date subr-x cl-loaddefs cl-lib
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel dos-w32 ls-lisp disp-table
term/w32-win w32-win w32-vars term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice
button loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads w32notify w32 lcms2 multi-tty
make-network-process native-compile emacs)
Memory information:
((conses 16 78996 5653)
(symbols 48 7157 0)
(strings 32 22876 2110)
(string-bytes 1 755191)
(vectors 16 14673)
(vector-slots 8 308167 12600)
(floats 8 30 232)
(intervals 56 376 0)
(buffers 992 11))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Wed, 09 Feb 2022 00:07:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 53885 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Tue, Feb 8, 2022 at 5:56 PM Corwin Brust <corwin <at> bru.st> wrote:
>
> Commentary:
>
> If the change is accpted, please consider fixing this for emacs-28.
> The reproducer represents a common use-case, e.g. see bug #31397.
> Moverover, it is a one-line change unlikely to affect anything aside
> this and similar use-cases.
>
Eli,
Would this be okay for the release branch or should I check if changes
are needed to rebase against master? Also, hould this receive a NEWS
entry?
> I will submit a patch as soon as I have a BugID from the tracker.
> Although this change is rather trivial I need to practice this
> process.
>
Now attached. TIA for tips and corrections.
[autoload_package-installed-p.patch (application/octet-stream, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Wed, 09 Feb 2022 05:40:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 53885 <at> debbugs.gnu.org (full text, mbox):
retitle 53885 28.0.91 [PATCH] Autoload package-installed-p
thanks
I inadvertently included an explicit call to `require' in the
reproducer, which functions as a work-around for this (IMO) missing
autoload. Sorry for any confusion caused.
>
> Reproducer:
>
> NOTE: Make sure you have a folder beneth your home directory called
> "elpa" and that it is empty.
>
> Launch emacs -Q
> Insert and evaluate:
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)))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Wed, 09 Feb 2022 13:39:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 53885 <at> debbugs.gnu.org (full text, mbox):
> From: Corwin Brust <corwin <at> bru.st>
> Date: Tue, 8 Feb 2022 18:05:45 -0600
>
> > Commentary:
> >
> > If the change is accpted, please consider fixing this for emacs-28.
> > The reproducer represents a common use-case, e.g. see bug #31397.
> > Moverover, it is a one-line change unlikely to affect anything aside
> > this and similar use-cases.
> >
>
> Eli,
>
> Would this be okay for the release branch or should I check if changes
> are needed to rebase against master? Also, hould this receive a NEWS
> entry?
>
> > I will submit a patch as soon as I have a BugID from the tracker.
> > Although this change is rather trivial I need to practice this
> > process.
> >
>
> Now attached. TIA for tips and corrections.
It's not really a bugfix, it's an enhancement. Not sure if it's
important enough for the release branch. But it's quite simple and
probably safe. Lars, WDYT?
(No need for a NEWS entry.)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Wed, 09 Feb 2022 14:40:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 53885 <at> debbugs.gnu.org (full text, mbox):
On Tue, 8 Feb 2022 at 23:39, Corwin Brust <corwin <at> 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).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Wed, 09 Feb 2022 15:41:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 53885 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi Augusto!
On Wed, Feb 9, 2022, 08:39 Augusto Stoffel <arstoffel <at> gmail.com> wrote:
>
> 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.
>
I believe this was changed with the implementation of "early-init". We
don't need to expressly call `package-refresh-contents' since Emacs 27, see:
https://github.com/emacs-mirror/emacs/blob/master/etc/NEWS.27#L227
> '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 wasn't aware of this idiosyncrasy. I will look at package.el further
FTR, in my own configuration I expressly set-up package-selected-packages.
In any case, this bug report stems from a Reddit user's perception of
breakage with the Emacs 28 pre-release binaries recently added to alpha. I
simply created a minimal reproducer from that person's use/expectations.
Do you agree the (corrected) reproducer given should be sufficient to
demonstrate the change provided by adding the autoload, if the patch is
applied?
As things stand presently, I'm having trouble thinking of use-cases for
package-installed-p that would not start with (require 'package).
> 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).
>
I love this idea. Would you be interested to open a new bug report for
this feature request, perhaps offering a patch if you are so inclined?
FWIW, I agree that ,if/when something more robust is added expressly to
support the batch installation of packages, the need for this autoload (and
perhaps all user-facing use-cases for package-installed-p) may be greatly
reduced.
That said, it's not clear to me whether general consensus will be to
support a "default automation" function (or functions) for this, or that
what we have is "enough" for each of us to do things as we wish. It might
make sense to open a discussion on the development list to discuss this
potential improvement.
Finally, in case it may help, here is a formula I have often used to
'bootstrap' a batch install of packages:
(setq package-selected-packages '(foo bar baz))
(mapc (lambda(pkg) (when (not (require pkg nil t) (package-install pkg))
package-selected-packages)
For myself, I'm not using `package-autoremove'. I typically remove
(actually rename, usually) my ELPA folder and then relaunch Emacs. My
configuration (just like the user on behalf of whom I reported this "bug"),
will then install the features I'm (still) using. I'm glad you are watching
out for people who do use the auto-remove package feature.
Regards,
Corwin
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Wed, 09 Feb 2022 20:17:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 53885 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> It's not really a bugfix, it's an enhancement. Not sure if it's
> important enough for the release branch. But it's quite simple and
> probably safe. Lars, WDYT?
It should be safe for the release branch, so installing it is fine by
me, but I didn't really understand the use case.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Wed, 09 Feb 2022 23:59:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 53885 <at> debbugs.gnu.org (full text, mbox):
On Wed, Feb 9, 2022 at 2:16 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
>
> It should be safe for the release branch, so installing it is fine by
> me, but I didn't really understand the use case.
Sorry I failed in making the case for users clear.
The primary use-case here is "repeatable configuration", especially
bootstrapping `use-package'.
By "repeatable configuration" we mean, we get the same setup each time
we start Emacs, even when launching for the first time on a new host.
The use package feature provides an "ensure" capability that is well
suited to this job.
(use-package 'foo :ensure t)
This appears widely used, especially to create literate Emacs configurations.
For this to work, however, "bootstrapping" (installing use-package via
Emacs core features) is needed. The reproducer I gave shows one way
of bootstrapping use-package. Considering the similarity of my
reproducer to the recipe in #31397, I think it is a fairly common
approach and has been for some years.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Thu, 10 Feb 2022 06:12:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 53885 <at> debbugs.gnu.org (full text, mbox):
> From: Corwin Brust <corwin <at> bru.st>
> Date: Wed, 9 Feb 2022 17:58:25 -0600
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 53885 <at> debbugs.gnu.org
>
> On Wed, Feb 9, 2022 at 2:16 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
> >
> > It should be safe for the release branch, so installing it is fine by
> > me, but I didn't really understand the use case.
>
> Sorry I failed in making the case for users clear.
>
> The primary use-case here is "repeatable configuration", especially
> bootstrapping `use-package'.
>
> By "repeatable configuration" we mean, we get the same setup each time
> we start Emacs, even when launching for the first time on a new host.
>
> The use package feature provides an "ensure" capability that is well
> suited to this job.
>
> (use-package 'foo :ensure t)
>
> This appears widely used, especially to create literate Emacs configurations.
>
> For this to work, however, "bootstrapping" (installing use-package via
> Emacs core features) is needed. The reproducer I gave shows one way
> of bootstrapping use-package. Considering the similarity of my
> reproducer to the recipe in #31397, I think it is a fairly common
> approach and has been for some years.
Thanks, but I don't think I understand the relevance, probably because
I don't use use-package. Why do you need package-installed-p to be
autoloaded in this scenario, and why cannot use-package do that by
itself?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Thu, 10 Feb 2022 06:46:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 53885 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> Thanks, but I don't think I understand the relevance, probably because
> I don't use use-package. Why do you need package-installed-p to be
> autoloaded in this scenario, and why cannot use-package do that by
> itself?
Yes, that's the puzzling thing. But I've never used use-package
myself -- I assumed that it was a framework built around package.el, but
perhaps it's not related to package.el at all?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Thu, 10 Feb 2022 07:23:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 53885 <at> debbugs.gnu.org (full text, mbox):
On Thu, Feb 10, 2022 at 12:45 AM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> > Thanks, but I don't think I understand the relevance, probably because
> > I don't use use-package. Why do you need package-installed-p to be
> > autoloaded in this scenario, and why cannot use-package do that by
> > itself?
>
> Yes, that's the puzzling thing. But I've never used use-package
> myself -- I assumed that it was a framework built around package.el, but
> perhaps it's not related to package.el at all?
>
I'm sure I follow the logic here. If use-package isn't installed, how
does it matter what relationship it may have to package.el?
That said, one can replace `use-package' with any feature not present
in Emacs as shipped.
Perhaps the use-case is more generally expressed as such:
I would like to have my init scripts automatically install a package
that isn't available "out of the box", but only if that feature hasn't
already been installed.
As things presently stand, `package-installed-p' is nearly perfect for
this, however one must take care to ensure package.el has been
manually loaded before calling it, in order to avoid Emacs raising the
error shown in the original report.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Thu, 10 Feb 2022 07:58:01 GMT)
Full text and
rfc822 format available.
Message #38 received at 53885 <at> debbugs.gnu.org (full text, mbox):
> From: Corwin Brust <corwin <at> bru.st>
> Date: Thu, 10 Feb 2022 01:21:59 -0600
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 53885 <at> debbugs.gnu.org
>
> On Thu, Feb 10, 2022 at 12:45 AM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
> >
> > Eli Zaretskii <eliz <at> gnu.org> writes:
> >
> > > Thanks, but I don't think I understand the relevance, probably because
> > > I don't use use-package. Why do you need package-installed-p to be
> > > autoloaded in this scenario, and why cannot use-package do that by
> > > itself?
> >
> > Yes, that's the puzzling thing. But I've never used use-package
> > myself -- I assumed that it was a framework built around package.el, but
> > perhaps it's not related to package.el at all?
> >
>
> I'm sure I follow the logic here. If use-package isn't installed, how
> does it matter what relationship it may have to package.el?
>
> That said, one can replace `use-package' with any feature not present
> in Emacs as shipped.
>
> Perhaps the use-case is more generally expressed as such:
>
> I would like to have my init scripts automatically install a package
> that isn't available "out of the box", but only if that feature hasn't
> already been installed.
>
> As things presently stand, `package-installed-p' is nearly perfect for
> this, however one must take care to ensure package.el has been
> manually loaded before calling it, in order to avoid Emacs raising the
> error shown in the original report.
Now I'm confused: which code calls package-installed-p in the
scenarios you have in mind? I thought it was use-package, but you
seem to say that's not the case?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Thu, 10 Feb 2022 08:10:02 GMT)
Full text and
rfc822 format available.
Message #41 received at 53885 <at> debbugs.gnu.org (full text, mbox):
On Thu, Feb 10, 2022 at 1:57 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> Now I'm confused: which code calls package-installed-p in the
> scenarios you have in mind? I thought it was use-package, but you
> seem to say that's not the case?
The user's Emacs configuration, e.g. init.el
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Thu, 10 Feb 2022 08:19:02 GMT)
Full text and
rfc822 format available.
Message #44 received at 53885 <at> debbugs.gnu.org (full text, mbox):
> From: Corwin Brust <corwin <at> bru.st>
> Date: Thu, 10 Feb 2022 02:09:34 -0600
> Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 53885 <at> debbugs.gnu.org
>
> On Thu, Feb 10, 2022 at 1:57 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
> >
> > Now I'm confused: which code calls package-installed-p in the
> > scenarios you have in mind? I thought it was use-package, but you
> > seem to say that's not the case?
>
> The user's Emacs configuration, e.g. init.el
Why do users do that without making sure the relevant feature is
loaded? And what makes package-installed-p special in this case?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Thu, 10 Feb 2022 08:42:02 GMT)
Full text and
rfc822 format available.
Message #47 received at 53885 <at> debbugs.gnu.org (full text, mbox):
Corwin Brust <corwin <at> bru.st> writes:
> I would like to have my init scripts automatically install a package
> that isn't available "out of the box", but only if that feature hasn't
> already been installed.
>
> As things presently stand, `package-installed-p' is nearly perfect for
> this, however one must take care to ensure package.el has been
> manually loaded before calling it, in order to avoid Emacs raising the
> error shown in the original report.
Oh, I see -- this has nothing to do with use-package, and you could have
used some other package manager. You just want to be able to check
whether a package is installed in .emacs (without saying `require
'package') which seems reasonable to me.
However, this comes firmly under "new functionality" and not "bug fix",
so I'm not sure we should put it in emacs-28 at this point, no matter
how innocuous it looks like. But if Eli thinks otherwise, I won't
object.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Thu, 10 Feb 2022 08:43:01 GMT)
Full text and
rfc822 format available.
Message #50 received at 53885 <at> debbugs.gnu.org (full text, mbox):
Hi Corwin,
On Wed, 9 Feb 2022 at 09:39, Corwin Brust <corwin <at> bru.st> wrote:
> Hi Augusto!
>
> On Wed, Feb 9, 2022, 08:39 Augusto Stoffel <arstoffel <at> gmail.com> wrote:
>
> 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.
>
> I believe this was changed with the implementation of "early-init". We don't need to expressly call
> `package-refresh-contents' since Emacs 27, see:
> https://github.com/emacs-mirror/emacs/blob/master/etc/NEWS.27#L227
This is a different matter. What I was saying is, you need to download
the package list from MELPA before trying to install a missing package.
If you delete ~/.emacs.d/elpa, your configuration as you showed it won't
be able to bootstrap.
> '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 wasn't aware of this idiosyncrasy. I will look at package.el further FTR, in my own configuration I
> expressly set-up package-selected-packages.
>
> In any case, this bug report stems from a Reddit user's perception of breakage with the Emacs 28
> pre-release binaries recently added to alpha. I simply created a minimal reproducer from that
> person's use/expectations.
>
> Do you agree the (corrected) reproducer given should be sufficient to demonstrate the change
> provided by adding the autoload, if the patch is applied?
>
> As things stand presently, I'm having trouble thinking of use-cases for package-installed-p that
> would not start with (require 'package).
>
> 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).
>
> I love this idea. Would you be interested to open a new bug report for this feature request, perhaps
> offering a patch if you are so inclined?
I recall Philip giving a similar suggestion on the mailing list but I
can't find that thread anymore. So I added him to this message.
> FWIW, I agree that ,if/when something more robust is added expressly to support the batch
> installation of packages, the need for this autoload (and perhaps all user-facing use-cases for
> package-installed-p) may be greatly reduced.
Autoloading 'package-installed-p' wouldn't cause any harm, but it also
doesn't solve any problems, so why bother?
> That said, it's not clear to me whether general consensus will be to support a "default automation"
> function (or functions) for this, or that what we have is "enough" for each of us to do things as we
> wish. It might make sense to open a discussion on the development list to discuss this potential
> improvement.
>
> Finally, in case it may help, here is a formula I have often used to 'bootstrap' a batch install of
> packages:
>
> (setq package-selected-packages '(foo bar baz))
> (mapc (lambda(pkg) (when (not (require pkg nil t) (package-install pkg))
> package-selected-packages)
>
> For myself, I'm not using `package-autoremove'. I typically remove (actually rename, usually) my
> ELPA folder and then relaunch Emacs. My configuration (just like the user on behalf of whom I
> reported this "bug"), will then install the features I'm (still) using. I'm glad you are watching out for
> people who do use the auto-remove package feature.
>
> Regards,
> Corwin
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Thu, 10 Feb 2022 08:50:02 GMT)
Full text and
rfc822 format available.
Message #53 received at 53885 <at> debbugs.gnu.org (full text, mbox):
On Thu, Feb 10, 2022 at 2:41 AM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
>
> Corwin Brust <corwin <at> bru.st> writes:
>
> > I would like to have my init scripts automatically install a package
> > that isn't available "out of the box", but only if that feature hasn't
> > already been installed.
> >
> > As things presently stand, `package-installed-p' is nearly perfect for
> > this, however one must take care to ensure package.el has been
> > manually loaded before calling it, in order to avoid Emacs raising the
> > error shown in the original report.
>
> Oh, I see -- this has nothing to do with use-package, and you could have
> used some other package manager. You just want to be able to check
> whether a package is installed in .emacs (without saying `require
> 'package') which seems reasonable to me.
Thanks much.
I've been struggling to reply to Ell's last succinctly, but maybe your
response has helped clarify and thus saved me from that.
Eli, please let me know if you have further what/why questions, otherwise
>
> However, this comes firmly under "new functionality" and not "bug fix",
> so I'm not sure we should put it in emacs-28 at this point, no matter
> how innocuous it looks like. But if Eli thinks otherwise, I won't
> object.
Fine by me either way.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Thu, 10 Feb 2022 09:00:03 GMT)
Full text and
rfc822 format available.
Message #56 received at 53885 <at> debbugs.gnu.org (full text, mbox):
Augusto Stoffel <arstoffel <at> gmail.com> writes:
>> 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).
>>
>> I love this idea. Would you be interested to open a new bug report for this feature request, perhaps
>> offering a patch if you are so inclined?
>
> I recall Philip giving a similar suggestion on the mailing list but I
> can't find that thread anymore. So I added him to this message.
Sadly I don't remember either, nor what the thread was about, but I
agree that such a function would be useful to have.
--
Philip Kaludercic
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Thu, 10 Feb 2022 09:24:02 GMT)
Full text and
rfc822 format available.
Message #59 received at 53885 <at> debbugs.gnu.org (full text, mbox):
On Thu, Feb 10, 2022 at 3:06 AM Augusto Stoffel <arstoffel <at> gmail.com> wrote:
>
> On Wed, 9 Feb 2022 at 09:39, Corwin Brust <corwin <at> bru.st> wrote:
>
> > On Wed, Feb 9, 2022, 08:39 Augusto Stoffel <arstoffel <at> gmail.com> wrote:
> >
> > 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.
> >
> > I believe this was changed with the implementation of "early-init". We don't need to expressly call
> > `package-refresh-contents' since Emacs 27, see:
> > https://github.com/emacs-mirror/emacs/blob/master/etc/NEWS.27#L227
>
> This is a different matter. What I was saying is, you need to download
> the package list from MELPA before trying to install a missing package.
This is taken care of by a call to package-installed-p in the case
where it does not receive a package description as the first argument
and when no min-version is passed, as in my "reproducer". Or maybe I
still don't understand.
> If you delete ~/.emacs.d/elpa, your configuration as you showed it won't
> be able to bootstrap.
I don't think I called for deleting anything; I just set-up a
non-standard place for the installation of packages. But I suspect
I'm missing your point.
>
> Autoloading 'package-installed-p' wouldn't cause any harm, but it also
> doesn't solve any problems, so why bother?
Here I don't agree. Consider:
(when (not (package-installed-p 'foo))
(package-install-package 'foo))
This seems to DTRT; the package does get installed whereas in the
present world a backtrace is triggered unless we first take care to
load package.el.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Thu, 10 Feb 2022 09:29:01 GMT)
Full text and
rfc822 format available.
Message #62 received at 53885 <at> debbugs.gnu.org (full text, mbox):
On Thu, 10 Feb 2022 at 08:59, Philip Kaludercic <philipk <at> posteo.net> wrote:
> Sadly I don't remember either, nor what the thread was about, but I
> agree that such a function would be useful to have.
IIRC, you suggested adding a file called site-lisp.el which included
some stuff useful in this context. In general I thought that little
library was a very good idea.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Thu, 10 Feb 2022 09:31:02 GMT)
Full text and
rfc822 format available.
Message #65 received at 53885 <at> debbugs.gnu.org (full text, mbox):
On Thu, 10 Feb 2022 at 03:23, Corwin Brust <corwin <at> bru.st> wrote:
>> If you delete ~/.emacs.d/elpa, your configuration as you showed it won't
>> be able to bootstrap.
>
> I don't think I called for deleting anything; I just set-up a
> non-standard place for the installation of packages. But I suspect
> I'm missing your point.
I thought your goal was to have Emacs download all the packages you need
if you copy your configuration files to a new computer. Maybe I
misunderstood.
>> Autoloading 'package-installed-p' wouldn't cause any harm, but it also
>> doesn't solve any problems, so why bother?
>
> Here I don't agree. Consider:
>
> (when (not (package-installed-p 'foo))
> (package-install-package 'foo))
>
> This seems to DTRT; the package does get installed whereas in the
> present world a backtrace is triggered unless we first take care to
> load package.el.
The first time you start Emacs, it doesn't have a list of packages from
ELPA et al (and even if you do, it may be out of date), so
'package-install-pakcage' will fail.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Thu, 10 Feb 2022 12:05:01 GMT)
Full text and
rfc822 format available.
Message #68 received at 53885 <at> debbugs.gnu.org (full text, mbox):
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 53885 <at> debbugs.gnu.org
> Date: Thu, 10 Feb 2022 09:41:40 +0100
>
> Oh, I see -- this has nothing to do with use-package, and you could have
> used some other package manager. You just want to be able to check
> whether a package is installed in .emacs (without saying `require
> 'package') which seems reasonable to me.
>
> However, this comes firmly under "new functionality" and not "bug fix",
> so I'm not sure we should put it in emacs-28 at this point, no matter
> how innocuous it looks like. But if Eli thinks otherwise, I won't
> object.
Those were my thoughts as well, so we agree here.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#53885
; Package
emacs
.
(Thu, 10 Feb 2022 14:55:01 GMT)
Full text and
rfc822 format available.
Message #71 received at 53885 <at> debbugs.gnu.org (full text, mbox):
On Thu, Feb 10, 2022 at 6:04 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > From: Lars Ingebrigtsen <larsi <at> gnus.org>
> >
> > However, this comes firmly under "new functionality" and not "bug fix",
> > so I'm not sure we should put it in emacs-28 at this point, no matter
> > how innocuous it looks like. But if Eli thinks otherwise, I won't
> > object.
>
> Those were my thoughts as well, so we agree here.
In that case..
I've confirmed my patch applies cleanly to master.
May I ask one of you to push it and then close this bug report (which
was actually a feature request)?
Thank you.
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Thu, 10 Feb 2022 17:30:03 GMT)
Full text and
rfc822 format available.
Notification sent
to
Corwin Brust <corwin <at> bru.st>
:
bug acknowledged by developer.
(Thu, 10 Feb 2022 17:30:03 GMT)
Full text and
rfc822 format available.
Message #76 received at 53885-done <at> debbugs.gnu.org (full text, mbox):
> From: Corwin Brust <corwin <at> bru.st>
> Date: Thu, 10 Feb 2022 08:54:28 -0600
> Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 53885 <at> debbugs.gnu.org
>
> I've confirmed my patch applies cleanly to master.
> May I ask one of you to push it and then close this bug report (which
> was actually a feature request)?
Done, thanks.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 11 Mar 2022 12:24:09 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 103 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.