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: Wed, 09 Feb 2022 15:39:34 +0100 Message-ID: <87a6f0nly1.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35971"; 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 Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 09 17:42:26 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 1nHq30-0009Af-1l for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 09 Feb 2022 17:42:26 +0100 Original-Received: from localhost ([::1]:36132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHq2y-0000tR-SG for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 09 Feb 2022 11:42:24 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:52294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHo8Y-0008Gu-Rk for bug-gnu-emacs@gnu.org; Wed, 09 Feb 2022 09:40:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56432) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHo8Y-00060w-Ft for bug-gnu-emacs@gnu.org; Wed, 09 Feb 2022 09:40:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nHo8Y-0000kn-DM for bug-gnu-emacs@gnu.org; Wed, 09 Feb 2022 09:40:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 09 Feb 2022 14:40:02 +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.16444175852868 (code B ref 53885); Wed, 09 Feb 2022 14:40:02 +0000 Original-Received: (at 53885) by debbugs.gnu.org; 9 Feb 2022 14:39:45 +0000 Original-Received: from localhost ([127.0.0.1]:50329 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHo8G-0000kC-Tv for submit@debbugs.gnu.org; Wed, 09 Feb 2022 09:39:45 -0500 Original-Received: from mail-ed1-f50.google.com ([209.85.208.50]:41840) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHo8F-0000k0-1d for 53885@debbugs.gnu.org; Wed, 09 Feb 2022 09:39:43 -0500 Original-Received: by mail-ed1-f50.google.com with SMTP id cz16so5475073edb.8 for <53885@debbugs.gnu.org>; Wed, 09 Feb 2022 06:39:42 -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=CaFihuXfbUrwchrRaSYxRu4r72JUFXadVud2odF/GHU=; b=oYiSd5JKkRLTXLrbBS64+j4yfkCVr/2XX10ID5MrOnR8lYV0gnpqDnGgt9gziLm2cz t4QqYUWZDmHTrDBTi+s1ZIBA/uL2O3NkWdmTmSdP14Ei6psFYzg/mGRoZzGq+0QbARJK ppijdXtcDqu3KLj2IxD07/N4Qu/KD2rmd/giwdm3WgdGdFScQX9WiXxej0EeAt9I72MZ QFJKCkQUsMwK0MqdOuzKyDBrFJ5Qwh0QbYiFBdd822wjiBnjmcuYgAb+hDH/e3f94pzD 75EgCg77zpyL9EfQFCS9wHTJFv+0lDiDZrXcKZU5LFXDLQvLcH5u1BbCKGSevtHeNrkQ P8ZQ== 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=CaFihuXfbUrwchrRaSYxRu4r72JUFXadVud2odF/GHU=; b=or7CNxOi2PMgivRMil+6tDYANjaGnf98q+Pi0u4Sad6KH/7OD+7JUvGMGKCoWfOhKr +JZD6Y8cSYOWiocDkG8ixH0v+JkEpT6hv49RjMzx8POlXCHvExWmLvjLROXTt4Stmov8 eXUgI02GefQyV0UMMuH1XKvvZXoStLlIRwBv7pnZ4D8bzz1WjsObcgZXGyxoJXQr6agC zpB0KEUzxp98NYXCtD4ef5plRSdfp7kQ4IyGp6RfhnD1rvSP9hpWduLT+b8DKsEu5O0p V6goj9IWqUXIgjRPZGQzb4qOvfVXMsFcWBHKMXQXz5MWKM0OxTf72nhB6BcZJjuGzIS4 klPw== X-Gm-Message-State: AOAM533BbP+yhZBs3hgfpuMUiaQZRNjjBVDLj2Zsq7qL4rKkwmYu/HDP D1o2hkIGvOYhsaKWKjVPU60= X-Google-Smtp-Source: ABdhPJyxfMNnjrcpNIuVnrBOCtbXl23sKg8+yjvFQ/Q4BJr2cg+rve2GnV/3FTzM1+DClJ/ok2Jwzg== X-Received: by 2002:aa7:df1a:: with SMTP id c26mr2848207edy.416.1644417575908; Wed, 09 Feb 2022 06:39:35 -0800 (PST) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::758e]) by smtp.gmail.com with ESMTPSA id s8sm5978591ejb.59.2022.02.09.06.39.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 06:39:35 -0800 (PST) In-Reply-To: (Corwin Brust's message of "Tue, 8 Feb 2022 23:39:37 -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:226491 Archived-At: On Tue, 8 Feb 2022 at 23:39, Corwin Brust 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).