From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Derek Upham via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#72453: 29.4; "use-package" macro does not load all expected related files Date: Sat, 03 Aug 2024 14:58:08 -0700 Message-ID: <87plqp9slr.fsf@priss.frightenedpiglet.com> Reply-To: Derek Upham Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39450"; mail-complaints-to="usenet@ciao.gmane.io" To: 72453@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 03 23:59:07 2024 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 1saMmJ-000A7x-0l for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 03 Aug 2024 23:59:07 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1saMlx-0003bR-Fi; Sat, 03 Aug 2024 17:58:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1saMlu-0003at-RJ for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2024 17:58:43 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1saMlu-0006Uv-H7 for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2024 17:58:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=Uj9KU9eHwJilTItcy0jnMSLyY5BipvqYDTrL4S2lFPA=; b=j5xL2BA6SPL/raLrf1SdaDHFbdiXYpRxuByjP0UvWVZ9t0WLax35FInm+9p9Yjb3bekBiwgTCG6od3kNBc9fGLcbene7Hg3l/7XJ7ulVB6hAl8QOGEG8p0t7Ucu+JYf3Le7HrGwZmI4RV0CrKboX9IkaovXPug6cxqbiqIYdbEKi1zfoj1GorMw5OFsN8+zbXBuXVUPOom97pphTtzSNWGlQAOJboh6xFfPREcmF7m3ic9ipOLg2tv9W17ASHTW1umq+Un786eNTxgkJRSjJ/+Omvaz5PsoKKsLXDL4jECg51q2N9NiMYDDNfSjW1VoIcKWXPm4RmtXz/NNm1oFqbQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1saMmE-0001BD-4H for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2024 17:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Derek Upham Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Aug 2024 21:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 72453 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.17227223264496 (code B ref -1); Sat, 03 Aug 2024 21:59:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Aug 2024 21:58:46 +0000 Original-Received: from localhost ([127.0.0.1]:54877 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1saMlx-0001AS-Pg for submit@debbugs.gnu.org; Sat, 03 Aug 2024 17:58:46 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:36474) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1saMlt-0001AC-KG for submit@debbugs.gnu.org; Sat, 03 Aug 2024 17:58:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1saMlY-0003YI-UG for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2024 17:58:21 -0400 Original-Received: from wilbur.contactoffice.com ([212.3.242.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1saMlW-0006SW-Jw for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2024 17:58:20 -0400 Original-Received: from smtpauth2.co-bxl (smtpauth2.co-bxl [10.2.0.24]) by wilbur.contactoffice.com (Postfix) with ESMTP id BFAAA13A6 for ; Sat, 3 Aug 2024 23:58:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1722722294; s=20240605-akrp; d=mailfence.com; i=derek_upham@mailfence.com; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; bh=Uj9KU9eHwJilTItcy0jnMSLyY5BipvqYDTrL4S2lFPA=; b=aJ1EOFGO8wm7l9d+lYYQjlrEcwONnc48YP9Sm1f0TBxJvXQVEci7eW4hPZp6Jnuq 7SwpifbhKfFEG2Ur5D4kGGCl/wWgroWbkJDJeW9RGVLaNrZtoFleUnivnU9a0O+bFGP 5IRz5A+qN2OWiMtHYfBsMZJwYhnBkWPTkipuMl2+GWN6rpZG0csyrml0ZoV7IqLKl4u ayDxcPv01FpQIFnPnLd0ZXbsqkrhymAl/tgcNT1Q39LHsTTB/szWBxkQlE+P3aKJ/KC CriNqaeCj4zWEUpxOLqJy5OLMo6CY8PLAeEAqcFoAyUqx+SBBYyGLwGOBj8R9YMwi6+ 1HwI9yNJQg== Original-Received: by smtp.mailfence.com with ESMTPSA for ; Sat, 3 Aug 2024 23:58:11 +0200 (CEST) Original-Received: from [::1] (helo=priss.frightenedpiglet.com) by priss.frightenedpiglet.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.97) (envelope-from ) id 1saMlM-00000000zUF-3sOr for bug-gnu-emacs@gnu.org; Sat, 03 Aug 2024 14:58:08 -0700 X-ContactOffice-Account: com:175140567 Received-SPF: pass client-ip=212.3.242.68; envelope-from=derek_upham@mailfence.com; helo=wilbur.contactoffice.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:289696 Archived-At: This problem exists for the current emacs-30 branch HEAD. The following "init.el" file contents provide a test case: (defun use-package-ensure-trace (name args state) (warn "use-package-ensure-trace %s %s %s" name args state) t) ;; (require 'use-package) (setq use-package-ensure-function 'use-package-ensure-trace) (setq use-package-always-ensure t) (use-package faces) (use-package ansi-color) (use-package files :ensure t) (use-package rx) (use-package avoid) Place it in a scratch directory "use-package-ensure-test" and invoke Emacs with, for example: emacs --init-directory use-package-ensure-test The init file sets use-package-always-ensure to true, and we expect trace warnings to show up for each use-package invocation. In fact, we only see them for the third and beyond. Warning (emacs): use-package-ensure-trace files (t) nil Warning (emacs): use-package-ensure-trace rx (t) nil Warning (emacs): use-package-ensure-trace avoid (t) nil Uncomment the "require" line in the init file and we see all of the traces that we expect: Warning (emacs): use-package-ensure-trace faces (t) nil Warning (emacs): use-package-ensure-trace ansi-color (t) nil Warning (emacs): use-package-ensure-trace files (t) nil Warning (emacs): use-package-ensure-trace rx (t) nil Warning (emacs): use-package-ensure-trace avoid (t) nil The root cause is the structure of the "use-package/use-package*.el" libraries. The "use-package" macro exists in "use-package-core.el", and has an autoload. When Emacs evalutes a use-package form, Emacs loads "use-package-core.el" only. It does not load any of the other "use-package*.el" components. That means that Emacs doesn't evaluate any of the `add-to-list' forms at the bottom of "use-package-ensure.el". As a result, the use-package-defaults mechanism doesn't start out with the expected :ensure or :pin behaviors. But the first time we refer to an :ensure property explicitly, that is enough to trigger the autoload of "use-package-handler/:ensure", which loads the file and sets up the defaults. All later invocations run the :ensure checks as expected. Moving the "use-package" macro into the top-level "use-package" file should fix the problem. The "use-package" file explicitly loads the other files, which sets up all of the defaults. In GNU Emacs 29.4 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.42, cairo version 1.18.0) of 2024-06-29, modified by Debian built on sbuild Windowing system distributor 'The X.Org Foundation', version 11.0.12101011 System Description: Debian GNU/Linux trixie/sid Configured using: 'configure --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/libexec --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --with-libsystemd --with-pop=yes --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/29.4/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/29.4/site-lisp:/usr/share/emacs/site-lisp --with-sound=alsa --without-gconf --with-mailutils --with-native-compilation --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/libexec --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --with-libsystemd --with-pop=yes --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/29.4/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/29.4/site-lisp:/usr/share/emacs/site-lisp --with-sound=alsa --without-gconf --with-mailutils --with-native-compilation --with-cairo --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/emacs-29.4+1=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB -- Derek Upham derek_upham@mailfence.com