From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#25819: 25.1; Added by Package.el. Added by Package.el. Added by Package.el. Added by Package.el. Date: Wed, 22 Feb 2017 21:28:02 -0500 Message-ID: <87zihdfxot.fsf@users.sourceforge.net> References: <20170220201438.GG1204@ofb.net> <8ttw7n1925.fsf@fencepost.gnu.org> <20170221230422.GJ1204@ofb.net> <20170222204852.GN1204@ofb.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1487816836 17650 195.159.176.226 (23 Feb 2017 02:27:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 23 Feb 2017 02:27:16 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: 25819@debbugs.gnu.org To: frederik@ofb.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Feb 23 03:27:10 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgj7c-0003w8-VQ for geb-bug-gnu-emacs@m.gmane.org; Thu, 23 Feb 2017 03:27:09 +0100 Original-Received: from localhost ([::1]:56068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgj7i-0000Uh-PW for geb-bug-gnu-emacs@m.gmane.org; Wed, 22 Feb 2017 21:27:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgj7a-0000Sf-B8 for bug-gnu-emacs@gnu.org; Wed, 22 Feb 2017 21:27:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgj7W-0004LM-By for bug-gnu-emacs@gnu.org; Wed, 22 Feb 2017 21:27:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53566) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cgj7W-0004LI-7u for bug-gnu-emacs@gnu.org; Wed, 22 Feb 2017 21:27:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cgj7V-00021I-VI for bug-gnu-emacs@gnu.org; Wed, 22 Feb 2017 21:27:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Feb 2017 02:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25819 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25819-submit@debbugs.gnu.org id=B25819.14878168197756 (code B ref 25819); Thu, 23 Feb 2017 02:27:01 +0000 Original-Received: (at 25819) by debbugs.gnu.org; 23 Feb 2017 02:26:59 +0000 Original-Received: from localhost ([127.0.0.1]:51765 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgj7S-00020x-Vn for submit@debbugs.gnu.org; Wed, 22 Feb 2017 21:26:59 -0500 Original-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 Original-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) Original-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) In-Reply-To: <20170222204852.GN1204@ofb.net> (frederik@ofb.net's message of "Wed, 22 Feb 2017 12:48:53 -0800") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:129672 Archived-At: --=-=-= 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 --=-=-=--