From unknown Sat Aug 16 10:43:41 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#24643 <24643@debbugs.gnu.org> To: bug#24643 <24643@debbugs.gnu.org> Subject: Status: 25.1; Don't call package--ensure-init-file if initialized during startup Reply-To: bug#24643 <24643@debbugs.gnu.org> Date: Sat, 16 Aug 2025 17:43:41 +0000 retitle 24643 25.1; Don't call package--ensure-init-file if initialized dur= ing startup reassign 24643 emacs submitter 24643 Alex severity 24643 minor tag 24643 fixed patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 08 13:21:05 2016 Received: (at submit) by debbugs.gnu.org; 8 Oct 2016 17:21:05 +0000 Received: from localhost ([127.0.0.1]:48934 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bsvJ3-0008FI-06 for submit@debbugs.gnu.org; Sat, 08 Oct 2016 13:21:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60657) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bsvJ1-0008EU-Iu for submit@debbugs.gnu.org; Sat, 08 Oct 2016 13:21:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bsvIv-0006BQ-A5 for submit@debbugs.gnu.org; Sat, 08 Oct 2016 13:20:58 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:54345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsvIv-0006BE-6V for submit@debbugs.gnu.org; Sat, 08 Oct 2016 13:20:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51603) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsvIt-0001PW-KW for bug-gnu-emacs@gnu.org; Sat, 08 Oct 2016 13:20:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bsvIq-00068c-EP for bug-gnu-emacs@gnu.org; Sat, 08 Oct 2016 13:20:55 -0400 Received: from mail-it0-x22b.google.com ([2607:f8b0:4001:c0b::22b]:32896) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsvIq-00068H-9E for bug-gnu-emacs@gnu.org; Sat, 08 Oct 2016 13:20:52 -0400 Received: by mail-it0-x22b.google.com with SMTP id k64so7083273itb.0 for ; Sat, 08 Oct 2016 10:20:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:mime-version; bh=mvfg0VhNRYzPFY62zhqcRsZnjH79ZcJbjanwbAjtSEA=; b=QueNsIHxbtMHxYhthU7Id2JtWj55ZVT71SOrUKhM7tublCXCHYBxhddPHPfMkLr4e9 QnKCUYijhs32HpyEh/pLgLGu7WmBCcv4WZBYadEdSZ82oNPwT7vB8vqIjmle4F9TabTy tLCQwNsjNSpwFOH9B5SfSqcLh4M9B33XaweRsK/t5rcsOV2YHoKuSvyTD4mds98RrtPe 2ZEFJZjqqNRBp1dF88UNDafM1tscsK3chnTQ55Ojt440hJrhECi0Y3Znnl8MXhqDuKJ1 EaeO1bEAO4iFDf8mDzrJo7e8r0FTDR2lVd6//9CrlOG1OiAOT5tXN1rYKQlTjN5CD0sk YGKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=mvfg0VhNRYzPFY62zhqcRsZnjH79ZcJbjanwbAjtSEA=; b=WQ69kpI1AwEV/xNvaWMoJP6TLAl2TKoSwQjpOMyoyqOg7a7ZLA3M96NBzBq9NpxSZF 85srGGf58Blur1Axu0RiaZWkqu3IxwxNcvLU3EFQk6aNwzDpaiM3HZ6yJZ5s7Ydo9jjI xntHUk60MOVSLDbRR4B8hbtxQqx0s+FilEFPEEakwKmuIx6DSOVXOXP0lO8eBioMqntb tKiVXPnmirZXRSgZw/nJDMF1DHrW2zYOcOBbtU38m7gTQny3JnRDccacOvIB38EQGIrT D4MB6SEqeLgVwmReeYQTusHJs7JAjIOhAAnNMHyQ/3ELutAKT1P8N+2Be3F1YB74BajS q6AA== X-Gm-Message-State: AA6/9RkdNEK2ElIPEghyNQk4wO6gPaXJ9sbGy+BIhylqOcFezyhSeWa0kI3J4W50nPUBfg== X-Received: by 10.36.105.71 with SMTP id e68mr3728419itc.121.1475947251328; Sat, 08 Oct 2016 10:20:51 -0700 (PDT) Received: from lylat (S01061859339e9903.ss.shawcable.net. [174.2.107.88]) by smtp.gmail.com with ESMTPSA id 140sm3374946itl.4.2016.10.08.10.20.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 08 Oct 2016 10:20:50 -0700 (PDT) From: Alex To: bug-gnu-emacs@gnu.org Subject: 25.1; Don't call package--ensure-init-file if initialized during startup Date: Sat, 08 Oct 2016 11:19:58 -0600 Message-ID: <87bmyuhi69.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) 'package-initialize' contains this if expression: #+BEGIN_SRC elisp (if (equal user-init-file load-file-name) ;; If `package-initialize' is being called as part of loading ;; the init file, it's obvious we don't need to ensure-init. (setq package--init-file-ensured t ;; And likely we don't need to run it again after init. package-enable-at-startup nil) (package--ensure-init-file)) #+END_SRC This calls 'package--ensure-init-file' even when a user may call 'package-initialize' in *one* of their init files, but not 'user-init-file'. I think the condition should be replaced with: #+BEGIN_SRC elisp (not after-init-time) #+END_SRC Then it won't ensure when the user has initialized their packages somewhere else. From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 22 21:26:58 2017 Received: (at control) by debbugs.gnu.org; 23 Feb 2017 02:26:59 +0000 Received: from localhost ([127.0.0.1]:51763 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgj7S-00020t-LU for submit@debbugs.gnu.org; Wed, 22 Feb 2017 21:26:58 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:36821) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgj7Q-00020e-8y; Wed, 22 Feb 2017 21:26:56 -0500 Received: by mail-it0-f67.google.com with SMTP id w185so369330ita.3; Wed, 22 Feb 2017 18:26:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=ZYkxnvskhRHA5bWgnNFvfOma5U5ssSvvSEry5ITaJiE=; b=ZO42270e8G8TalHMUNIEW6dUGA3051CGOWCs09zMBjfbWYR/ISYvUSdkPbUG8qiNoi 4I8mrPfnmwr84UHLiU1pPrKqxhhV5+6d4H5DCqcu+ZymwD3Hhw/d5/w8LOmRShdig8uO Bv0QePW+IEtd7JSPfwBrAP0J2uiXTq0vqHtYYNaAhMXQwdKpXsaJ3yiM0OBqwSFENcyJ 6K+p6kWXsjIXAhp2oMXoFHd7ozWZRKiwqj8+J5GI6vZlJiedhwt2F2OTQZaWRzpck7mu b+Zr0PSdVUN5kQgMPsz9LAM4iZvLjLI28zsE6UDZBL3iELHe5MgiP1wdCkhRqXVfz7BE oP9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=ZYkxnvskhRHA5bWgnNFvfOma5U5ssSvvSEry5ITaJiE=; b=sl5rxa/h6NhAOfY7WJwf1g7DuRrNYzdzcGEcb4jAXrsb07+GlyYGvYiT1wtAlLJmUG BRKMBtNiko+Tx5+RWUyfbJeoYp/LloMY8c/oAefyP6krbpk8aqOUawN+x73cuRpeAxiy e8Ck1oeX8Aj2nunST/YOj1Md/jij0L1SeT8NrPhvrquvi6EG3QFD2LsyCSmZ1S/IGjVB L3lrP/Zp27iL6RoON8Wy3WpQedgx7nxdfFEX19E30FvsxgvBO0yGpDAsj/iHyDi/Wk0m aIOW+j3COqW8cd6Z+Dd1bQnyPhDZmtVMoCpGWTIqAT9zRU0gNQYOLxMw3qyTiIZ61Jjf 5LsA== X-Gm-Message-State: AMke39m7Fe5nY/bjux2jY4NAPxxOVwWAcvA0nz9TAUa1fflkzLVvdBWjhXouXEKoq/3YRA== X-Received: by 10.36.94.66 with SMTP id h63mr1860746itb.41.1487816810730; Wed, 22 Feb 2017 18:26:50 -0800 (PST) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id m77sm1304349ita.16.2017.02.22.18.26.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Feb 2017 18:26:50 -0800 (PST) From: npostavs@users.sourceforge.net To: frederik@ofb.net Subject: Re: bug#25819: 25.1; Added by Package.el. Added by Package.el. Added by Package.el. Added by Package.el. References: <20170220201438.GG1204@ofb.net> <8ttw7n1925.fsf@fencepost.gnu.org> <20170221230422.GJ1204@ofb.net> <20170222204852.GN1204@ofb.net> Date: Wed, 22 Feb 2017 21:28:02 -0500 In-Reply-To: <20170222204852.GN1204@ofb.net> (frederik@ofb.net's message of "Wed, 22 Feb 2017 12:48:53 -0800") Message-ID: <87zihdfxot.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: control Cc: 25819@debbugs.gnu.org, Glenn Morris X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) --=-=-= Content-Type: text/plain forcemerge 25819 24643 tags 25819 patch quit frederik@ofb.net writes: > On Wed, Feb 22, 2017 at 02:28:27PM -0500, Glenn Morris wrote: >> >> I tested with: >> >> /tmp/h1/.emacs: >> (setenv "HOME" "/tmp/h2/") >> (setq savehist-file "/tmp/h1/.emacs-history") >> (load "~/.emacs") >> (setenv "HOME" "/tmp/h1/") >> >> /tmp/h2/.emacs: >> (setq foo 99) >> >> >> HOME=/tmp/h1 emacs-25.1 >> M-x package-initialize > > You don't think my problem is common!? :) Well I'm not sure how other > people edit files as root, Probably with TRAMP: https://www.emacswiki.org/emacs/TrampMode#toc20 > Thank you (indeed) for taking the time to trim down my problem to a > minimal test case. If we make it a little less minimal: > > /tmp/h2/.emacs: > (setq foo 99) > (package-initialize) > > then I find it reproduces the problem: AFAICT, this is essentially the problem described in #24643 and should be fixed by the suggestion there: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Don-t-call-package-ensure-init-file-if-initialize.patch Content-Description: patch >From aeae23ab082e948eca71ead3ea50a49a4fe73251 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Wed, 22 Feb 2017 21:12:41 -0500 Subject: [PATCH v1] Don't call package--ensure-init-file if initialized during startup * lisp/emacs-lisp/package.el (package-initialize): Check `after-init-time' rather than `load-file-name' to decide if `package--ensure-init-file' should be called. Depending on `load-file-name' will fail if the user calls `pacakge-initialize' in file which is loaded from the init file (Bug#24643, Bug#25819). --- lisp/emacs-lisp/package.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 0851c5e1fd..ee4bb750ab 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -1445,13 +1445,13 @@ package-initialize taken care of by `package-initialize'." (interactive) (setq package-alist nil) - (if (equal user-init-file load-file-name) - ;; If `package-initialize' is being called as part of loading - ;; the init file, it's obvious we don't need to ensure-init. - (setq package--init-file-ensured t - ;; And likely we don't need to run it again after init. - package-enable-at-startup nil) - (package--ensure-init-file)) + (if after-init-time + (package--ensure-init-file) + ;; If `package-initialize' is before we finished loading the init + ;; file, it's obvious we don't need to ensure-init. + (setq package--init-file-ensured t + ;; And likely we don't need to run it again after init. + package-enable-at-startup nil)) (package-load-all-descriptors) (package-read-all-archive-contents) (unless no-activate -- 2.11.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 26 11:17:49 2017 Received: (at control) by debbugs.gnu.org; 26 Feb 2017 16:17:50 +0000 Received: from localhost ([127.0.0.1]:56945 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ci1W9-0003om-NM for submit@debbugs.gnu.org; Sun, 26 Feb 2017 11:17:49 -0500 Received: from mail-it0-f65.google.com ([209.85.214.65]:35075) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ci1W8-0003oV-6x; Sun, 26 Feb 2017 11:17:48 -0500 Received: by mail-it0-f65.google.com with SMTP id 203so9145440ith.2; Sun, 26 Feb 2017 08:17:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=RjnVlzrstibBCb/q7u0wV77qzwCWLbPHCnMHSu8Pr/s=; b=VPuzNL8hB6a6PulZLrQjm87wdOqRXvDThhWShl65Ybwiq99QXaSXxHKoXE4GC/K54P ioUZPXVjITpL2JQZGf0CgFz0yrurubbLjdGSbqpTSxpR4q4BZrz4yt8y0mkxZPyo10p8 +090xy2s3FlvrJkuompLrC1FW9SaiOk2FE6o5vd6a6JOVclfY9v9+s83hlGLXl+oOIcX a8Q5tyEn1hF1XpvAlJft0O8WHzej3m2/3P6Z7ceLQAmBuIWkpWvAKTRLuD6pCs9kTYtC OgGkPEwtfQ6IKF5x8tXL/4DJI+ryIoBUujm9jV4pKduq8tx6+O7QR6HP9ImWSTjhTYB1 4Bag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=RjnVlzrstibBCb/q7u0wV77qzwCWLbPHCnMHSu8Pr/s=; b=kmJ61JTgVMxU4njEomaD9QD3zW1WTfWUJ706cs5rmM4Op4MkfCLiJYUh6kbVIJR2iL FGikYDj3Ru5C4p1rsho+kk+vcp0ToP/JfoGMsJ/XGlgM/TD1S6wSoUnFsKD3UIMrGWxM zxj1tkTr9m9v/vJPrfAh7yRpf1i05Yto2ClIfUidb/XO6+9eWzBdWhDE8c8MxjZw76sl q8lO0lcLZbMHB9EUfyNpni5fQnBsGFm+VDnTwkaIYy6EnETwhQg0o+Zi8Adpe1iSVCW5 qwhoRdeTfCBn1AmLFHf5/fXNQkKePaIcMM2r7onzflfKS7deMrpJH39kSemEAuvGLXt1 /D8Q== X-Gm-Message-State: AMke39mQ3wHK7h7tuwtV1cQTvjEN4+pD9oiC+Qqc2dg+gPkivBy4VO56Bz2zpTaryj9C2w== X-Received: by 10.36.65.4 with SMTP id x4mr10964723ita.69.1488125862832; Sun, 26 Feb 2017 08:17:42 -0800 (PST) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id r85sm3296605itc.13.2017.02.26.08.17.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 26 Feb 2017 08:17:42 -0800 (PST) From: npostavs@users.sourceforge.net To: frederik@ofb.net Subject: Re: bug#25819: 25.1; Added by Package.el. Added by Package.el. Added by Package.el. Added by Package.el. References: <20170220201438.GG1204@ofb.net> <8ttw7n1925.fsf@fencepost.gnu.org> <20170221230422.GJ1204@ofb.net> <20170222204852.GN1204@ofb.net> <87zihdfxot.fsf@users.sourceforge.net> <20170223062351.GR1204@ofb.net> Date: Sun, 26 Feb 2017 11:18:55 -0500 In-Reply-To: <20170223062351.GR1204@ofb.net> (frederik@ofb.net's message of "Wed, 22 Feb 2017 22:23:51 -0800") Message-ID: <87shn1dixc.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: control Cc: 25819@debbugs.gnu.org, Glenn Morris X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) tags 25819 fixed close 25819 26.1 quit frederik@ofb.net writes: > Thank you! > >> >> AFAICT, this is essentially the problem described in #24643 and should be >> fixed by the suggestion there: Pushed to master [1: 6b6cc56e72]. 1: 2017-02-26 11:11:40 -0500 6b6cc56e728a4d8b5ccac86ac393be7cd29207e2 Don't call package--ensure-init-file if initialized during startup From unknown Sat Aug 16 10:43:41 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 27 Mar 2017 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator