From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.bugs Subject: bug#53885: Autoload package-installed-p Date: Thu, 10 Feb 2022 09:42:41 +0100 Message-ID: <87y22jm7su.fsf@gmail.com> References: <87a6f0nly1.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39584"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux) Cc: Lars Ingebrigtsen , 53885@debbugs.gnu.org To: Corwin Brust , Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 10 10:06:20 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nI5PA-000A7f-0x for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 10 Feb 2022 10:06:20 +0100 Original-Received: from localhost ([::1]:56060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI5P8-0001Xh-BD for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 10 Feb 2022 04:06:18 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:54062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI52c-0001wO-9m for bug-gnu-emacs@gnu.org; Thu, 10 Feb 2022 03:43:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59966) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI52b-0003sq-VI for bug-gnu-emacs@gnu.org; Thu, 10 Feb 2022 03:43:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nI52b-0004qo-U4 for bug-gnu-emacs@gnu.org; Thu, 10 Feb 2022 03:43:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 10 Feb 2022 08:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53885 X-GNU-PR-Package: emacs Original-Received: via spool by 53885-submit@debbugs.gnu.org id=B53885.164448257218628 (code B ref 53885); Thu, 10 Feb 2022 08:43:01 +0000 Original-Received: (at 53885) by debbugs.gnu.org; 10 Feb 2022 08:42:52 +0000 Original-Received: from localhost ([127.0.0.1]:53863 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nI52S-0004qN-Bc for submit@debbugs.gnu.org; Thu, 10 Feb 2022 03:42:52 -0500 Original-Received: from mail-ed1-f43.google.com ([209.85.208.43]:38667) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nI52Q-0004q6-43 for 53885@debbugs.gnu.org; Thu, 10 Feb 2022 03:42:51 -0500 Original-Received: by mail-ed1-f43.google.com with SMTP id cn6so9619525edb.5 for <53885@debbugs.gnu.org>; Thu, 10 Feb 2022 00:42:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=T0JIJGvqEBwKoCyKo2aRYnIa1YDK9ZNHdfyQNM9Mius=; b=L3oRdaW0ak79x0jiyMsBodcl8EtET2bzmjAqMphvaeFXvvddSIZpZvQ5R6Ud5rQlx4 TBtT/C4Vh5pGWzwifEp8jnUvU347NW138sR6Y5Xb41CZuA0Vlmy0NcuKxWEvupj5eUBs 3j31rgn30EDlSYO0R21jutCToDGbSXTGwCykwBpDlVd1SxLjEfMD+CYR2Iv9wuGMfnxp n99nTFMqlYLG7c8usCYfXVLcL4gVZK3BfItAHXUmLK0IOHfswy/m8KDreSlmeJMsWwTk 6Fm3C8hfq15NpaWPFplW/MHnDLqLpU+3aXC74Tipoz8CfhOI5PZ6YNs7VtxWAeY4nDYp Ydzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=T0JIJGvqEBwKoCyKo2aRYnIa1YDK9ZNHdfyQNM9Mius=; b=xO8qgyTqffKT6zqRs6uZaL7Yen//WehrR2BelW+JB+EE7WWPnM7CZ3B3VS3H3SqTW7 CIsITMaEEv3kHjNMmdQa2L4y9pQ8EXWqsE6GU2e+QaJRFypps9x5oQSt+r4utaVs31cG VW0pv9XPg4hMFWtcElj/OOczg/OQuBLrqreG1agI38x2uL+xbw0r0vZ2DqQYwx1ByFJU IO2151lgb29r8ZQAUNyE7NXeNX0eKko3cQujh3U1HdFtxvFVtRN/XKwPRi1aMncAwKkg Okad2RX4mC6q2UuDSBwdOAjH54m8BBODmRSpgwfXc1wl/Hla6JOAC/HvCmYdfw0TLA65 DbhA== X-Gm-Message-State: AOAM531hundzRj8Pa6BWH+dHmrwd3b31Ro6KbYZE3o+svkhKnJ/D55Vu QLAH7yEPaeSJwhexwbF7dQU= X-Google-Smtp-Source: ABdhPJzxiZhJRa13A6fE4kmIffiPub/x1KyhwZ06PROeFtUQqI4JuuHKLFTQBBbbV2+QXHVyLHG4+g== X-Received: by 2002:a05:6402:5145:: with SMTP id n5mr7209248edd.109.1644482564106; Thu, 10 Feb 2022 00:42:44 -0800 (PST) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::758e]) by smtp.gmail.com with ESMTPSA id eo14sm6071610edb.46.2022.02.10.00.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:42:43 -0800 (PST) In-Reply-To: (Corwin Brust's message of "Wed, 9 Feb 2022 09:39:46 -0600") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:226571 Archived-At: Hi Corwin, On Wed, 9 Feb 2022 at 09:39, Corwin Brust wrote: > Hi Augusto! > > On Wed, Feb 9, 2022, 08:39 Augusto Stoffel 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