From unknown Sun Aug 17 09:10:30 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#77468 <77468@debbugs.gnu.org> To: bug#77468 <77468@debbugs.gnu.org> Subject: Status: 30.1.50; package-quickstart file is not relocatable Reply-To: bug#77468 <77468@debbugs.gnu.org> Date: Sun, 17 Aug 2025 16:10:30 +0000 retitle 77468 30.1.50; package-quickstart file is not relocatable reassign 77468 emacs submitter 77468 Spencer Baugh severity 77468 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 02 14:46:08 2025 Received: (at submit) by debbugs.gnu.org; 2 Apr 2025 18:46:09 +0000 Received: from localhost ([127.0.0.1]:59386 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u036D-0005CZ-HM for submit@debbugs.gnu.org; Wed, 02 Apr 2025 14:46:08 -0400 Received: from lists.gnu.org ([2001:470:142::17]:57556) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u036A-0005Bz-QQ for submit@debbugs.gnu.org; Wed, 02 Apr 2025 14:46:03 -0400 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 1u0364-0001yb-Vj for bug-gnu-emacs@gnu.org; Wed, 02 Apr 2025 14:45:56 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u0363-0004hl-Cy for bug-gnu-emacs@gnu.org; Wed, 02 Apr 2025 14:45:56 -0400 From: Spencer Baugh To: bug-gnu-emacs@gnu.org Subject: 30.1.50; package-quickstart file is not relocatable X-Debbugs-Cc: Stefan Monnier Date: Wed, 02 Apr 2025 14:45:53 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1743619553; bh=GhpXHkVn9esV+F1Aff4PM7KiJjQx5GI9xggaXMxgmMM=; h=From:To:Subject:Date; b=YU7oRd+U4q573bfA56K+1MNz6aUXy69HZRljS0Koc2WUbwDACIOPOlY82i1NQdI5x I2otwSJh5CRjlEASuGXMyOHuo6sL/ai2fStNxLvxiL54lmiP/EZoEa2zKIXrpdzYnp P+e0HDBJT5lfehYYrcZLD+AO79qYwsTQeFd3Y7OEqTJYr6tqWcEFUGij6TsHWrBKku PfuLsHQiEqUS42Thw2FWFTV26UQBXshb4NgvRahXiT7DNWgdlx2arttoRMhf/6PhUP XyZgSNOfFGIYxIiOXzRXl8i/jRCd5gzHhiMgwK4n3ZQuNqD3Gq6H+fUunUTznxctM2 183zr/W6vFA1A== Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) 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: -1.0 (-) The package-quickstart file hardcodes various absolute file names. This means it can't be used in situations where the package directory might be at different absolute names at package-quickstart-refresh time and at usage time. For example: - network filesystems where the user's home directory has a different absolute name on different hosts - a system-wide package-directory-list entry which has a package-quickstart file generated for it at build time which has a different absolute name at install time (this is my use case; there are other problems with it, but the absolute names are the biggest one) I think we should make package-quickstart use file names which are relative to the location of the package-quickstart file itself. I'm happy to write the patch for this if that sounds reasonable. From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 02 15:48:24 2025 Received: (at 77468) by debbugs.gnu.org; 2 Apr 2025 19:48:24 +0000 Received: from localhost ([127.0.0.1]:59579 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u044V-00081Y-ND for submit@debbugs.gnu.org; Wed, 02 Apr 2025 15:48:23 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:40103) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u044T-00081L-Mo for 77468@debbugs.gnu.org; Wed, 02 Apr 2025 15:48:22 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 228C8442E1E; Wed, 2 Apr 2025 15:48:14 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1743623293; bh=uN+rIEP+1VwF6tLEXH4tpYt9O6gz1AFQnxUdgN5L0/4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=lpxbr8BrY2oGB8XQYCRgGg1kSfphfcWwc6jrAmjuu+dbDv8+YYL9q4NOQx5UGZ3Qc LG2/kFLMWzM8S5sAfc2V83WRJCzVtXJe18JM9Ydf6O+E7kJJDCGDebclh0UcEW11Bd dHbMIxKXKJUlsNBo9vbe7uKr+g/ns+6vQ6UXGxlQdkH2u6ik3RBeP9q7NaGOPCwKRJ FFoKVJg4GzTiy2Y+Gbatkao/FZdOWMxuX47BBLHQMHo3Os/6RJn9AtdLlAmNJl9REo bcDfOmfZHPes/SjH4ud0Q7SDzxhnej8yGx92VqM/qNhzT8WJDUVf1vBeti0i0xJqrb Xp9OKL4rWToWQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 09C4B442DDA; Wed, 2 Apr 2025 15:48:13 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id F16991202D5; Wed, 2 Apr 2025 15:48:12 -0400 (EDT) From: Stefan Monnier To: Spencer Baugh Subject: Re: bug#77468: 30.1.50; package-quickstart file is not relocatable In-Reply-To: Message-ID: References: Date: Wed, 02 Apr 2025 15:48:12 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.216 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77468 Cc: 77468@debbugs.gnu.org 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: -3.3 (---) > I think we should make package-quickstart use file names which are > relative to the location of the package-quickstart file itself. It would probably slow down startup a little bit since `package-quickstart.el` (PQ) would need to `expand-file-name` every time it binds `load-file-name`, but yes I think it would be a good change. There is still the problem that the relative file names may themselves break when your `package-directory-list` has directories that are outside of the home directory. Actually, now that I think about it, the change you suggest would break one of my use cases (where my packages are always at the same place, outside of $HOME, but $HOME does move). Hmm... Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 02 15:54:25 2025 Received: (at 77468) by debbugs.gnu.org; 2 Apr 2025 19:54:25 +0000 Received: from localhost ([127.0.0.1]:59614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u04AK-0008HY-Mh for submit@debbugs.gnu.org; Wed, 02 Apr 2025 15:54:25 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:50323) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u04AH-0008HJ-T8 for 77468@debbugs.gnu.org; Wed, 02 Apr 2025 15:54:22 -0400 From: Spencer Baugh To: Stefan Monnier Subject: Re: bug#77468: 30.1.50; package-quickstart file is not relocatable In-Reply-To: (Stefan Monnier's message of "Wed, 02 Apr 2025 15:48:12 -0400") References: Date: Wed, 02 Apr 2025 15:54:16 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1743623656; bh=DdN98qlxzZ5f7vOR/x/Nb6MIcPDjH0UUOxdFfUVsB6c=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=cEvgyhdeJKYwV7cC4Rfbbcfzkvu5Zuw5WSLNz7G4aZ2kRJHhRBZRkCrKY6X2bMSHt 8sZuDmx0k4+eM/oPFRyAKROKkyQUmy8VXsr22kG4/+TZ/HZLD/NVwi2LHbHrgcw/QI 8cflGomoNQDid61NbXVk3ur0jIGF6ic5RkZ4zOHOPheZqHUtTxJcGKb94DiiO5vCGH bxLDATNNhSeGb1dL+Pj3izumb2hIe6RjkDAvSnpAQGz0hTRaF7Gmn5W9Av5mDhpJVo qcpO157NRq2fbgPK9x7SBQZq6eBq/j/yI5nhQcopyy27nafs6ZOkMqDinGJZES8dm9 usSVrABkr0zKQ== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77468 Cc: 77468@debbugs.gnu.org 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: -3.3 (---) Stefan Monnier writes: >> I think we should make package-quickstart use file names which are >> relative to the location of the package-quickstart file itself. > > It would probably slow down startup a little bit since > `package-quickstart.el` (PQ) would need to `expand-file-name` every time > it binds `load-file-name`, but yes I think it would be a good change. > > There is still the problem that the relative file names may themselves > break when your `package-directory-list` has directories that are > outside of the home directory. > > Actually, now that I think about it, the change you suggest would break > one of my use cases (where my packages are always at the same place, > outside of $HOME, but $HOME does move). Oh, right. I didn't think of the case where package-quickstart.el refers to packages outside the directory it lives in. I definitely don't think package-quickstart.el should use relative names to those packages - that would be quite weird - and I do expect it would break some use cases. Maybe package-quickstart.el could use relative names to packages in package-user-dir (since it itself lives in package-user-dir), and absolute names to packages outside that? That would also fix my issue and I'd be happy to implement it. From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 02 16:24:48 2025 Received: (at 77468) by debbugs.gnu.org; 2 Apr 2025 20:24:48 +0000 Received: from localhost ([127.0.0.1]:59686 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u04dk-0001GZ-H0 for submit@debbugs.gnu.org; Wed, 02 Apr 2025 16:24:48 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:10489) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u04di-0001GC-6V for 77468@debbugs.gnu.org; Wed, 02 Apr 2025 16:24:46 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 7BDFC10004C; Wed, 2 Apr 2025 16:24:39 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1743625478; bh=X0tnMWzarrjaNms4aFpCCT0TA1eWozfb5JkaZvOua/Q=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=VFcd7yuQblQpxksDPizQEWfqB/bT/FksqREqVKk27dLS0Vpmp5TdNXoCFtrNmhXQr z5PvrBOGppkrGUCROqWd2xT6X98i+bVYmKfEKV9+FBs8hY/kOqMGtvmkgFRhelhXb+ 5EMzZ69jzZNCZ5ZPPNTlzgUvWx1+BSPPyaF254spMJVsF47447s9wZ9vSGqC7YW0N1 46XC0hb/MH5O4/ch1Y8FD93C31BPPFLU7joOXZUDAVVbvGU8zg93a1V1SWZvIPTpsR CMU4v9ma20umDczwUFDUZ2iU+BUtaOszjTczANr4/7Ng0h23WGJEMK6C/XgLz/w9+I vo0BjrB6gzidg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id B08DA100029; Wed, 2 Apr 2025 16:24:38 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A0C4B1203A5; Wed, 2 Apr 2025 16:24:38 -0400 (EDT) From: Stefan Monnier To: Spencer Baugh Subject: Re: bug#77468: 30.1.50; package-quickstart file is not relocatable In-Reply-To: Message-ID: References: Date: Wed, 02 Apr 2025 16:24:38 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.105 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77468 Cc: 77468@debbugs.gnu.org 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: -3.3 (---) > Maybe package-quickstart.el could use relative names to packages in > package-user-dir (since it itself lives in package-user-dir), and > absolute names to packages outside that? Sounds OK. Tho maybe we should check `file*-in-directory-p` (or the presence of "../" in the output of `file-relative-name`) rather than distinguishing based on `package-user-dir` vs `package-directory-list`? In any case, it sounds like a good compromise. Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 02 17:22:31 2025 Received: (at 77468) by debbugs.gnu.org; 2 Apr 2025 21:22:31 +0000 Received: from localhost ([127.0.0.1]:59789 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u05Xb-0003wg-7w for submit@debbugs.gnu.org; Wed, 02 Apr 2025 17:22:31 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:53905) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u05XX-0003wR-V5 for 77468@debbugs.gnu.org; Wed, 02 Apr 2025 17:22:28 -0400 From: Spencer Baugh To: Stefan Monnier Subject: Re: bug#77468: 30.1.50; package-quickstart file is not relocatable In-Reply-To: (Stefan Monnier's message of "Wed, 02 Apr 2025 16:24:38 -0400") References: Date: Wed, 02 Apr 2025 17:22:22 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1743628942; bh=QFqrwc63gd++ZHr5PTR72DH/gg7cymWrBc9F+OKQ2eI=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=0WBkIcyMUjB+3v8eed/DfCPPgjsHxWWuydlwNpFeSMeSNHKExIsPyzZGQwsiEe1d5 xYbdsEpu+8VcVCqk74Idp+T3/PMJb7fzcgIXj9HyvpTX9DR89BDlJIOct7TpVMfwho /m3rbe0bsqhsR54/9+c+OZoz0O9wnNTZaHYHtbTxjEtku9P/4HrL7qums+fSpuRzgt R/Wv8ymgm/b1Tj0C6wxg7SQoXIBTgJcvUbcreQlxDUCBvyG7MmSlXpUYoXAJQ+8RLr j4rlexfItRcF9YGKNqhHSQ/P/pTL3RevIT7voIk+5VSxiKHslo0WwHe88/PlIR/o+D 6K2/a5eKk5H6Q== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77468 Cc: 77468@debbugs.gnu.org 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: -3.3 (---) --=-=-= Content-Type: text/plain Stefan Monnier writes: >> Maybe package-quickstart.el could use relative names to packages in >> package-user-dir (since it itself lives in package-user-dir), and >> absolute names to packages outside that? > > Sounds OK. Tho maybe we should check `file*-in-directory-p` (or the > presence of "../" in the output of `file-relative-name`) rather than > distinguishing based on `package-user-dir` vs `package-directory-list`? > > In any case, it sounds like a good compromise. Makes sense. How about this? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Use-relative-names-where-possible-in-package-quickst.patch >From 7f465bee1605e0687f4f7713bcfeb9ac39b28355 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Wed, 2 Apr 2025 17:21:24 -0400 Subject: [PATCH] Use relative names where possible in package-quickstart.el package-quickstart.el hardcodes many absolute file names, which makes it break if user-emacs-directory moves, or in other situations. To be slightly more robust to this, use relative file names to packages that are located in the same directory as package-quickstart.el. * lisp/emacs-lisp/package.el (package--quickstart-relative): Add. (package-quickstart-refresh): Use package--quickstart-relative on file names. (bug#77468) --- lisp/emacs-lisp/package.el | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index b9a8dacab15..1269a9c95e7 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -4591,6 +4591,14 @@ package--quickstart-maybe-refresh (delete-file (concat package-quickstart-file "c")) (delete-file package-quickstart-file))) +(defun package--quickstart-relative (load-name file) + "Return an expression which evaluates to FILE while loading LOAD-NAME." + (let* ((dir (file-name-directory (expand-file-name load-name))) + (relname (file-relative-name file dir))) + (if (string-prefix-p ".." relname) + file + `(file-name-concat (file-name-directory load-file-name) ,relname)))) + (defun package-quickstart-refresh () "(Re)Generate the `package-quickstart-file'." (interactive) @@ -4605,7 +4613,8 @@ package-quickstart-refresh ;; aren't truncated. (print-length nil) (print-level nil) - (Info-directory-list '(""))) + (Info-directory-list '("")) + (qs-dir (file-name-directory (expand-file-name package-quickstart-file)))) (dolist (elt package-alist) (condition-case err (package-activate (car elt)) @@ -4622,7 +4631,7 @@ package-quickstart-refresh ;; Prefer uncompiled files (and don't accept .so files). (let ((load-suffixes '(".el" ".elc"))) (locate-library (package--autoloads-file-name pkg)))) - (pfile (prin1-to-string file))) + (pfile (prin1-to-string (package--quickstart-relative package-quickstart-file file)))) (insert "(let* ((load-file-name " pfile ")\ \(load-true-file-name load-file-name))\n") (insert-file-contents file) @@ -4638,7 +4647,10 @@ package-quickstart-refresh (append ',(mapcar #'package-desc-name package--quickstart-pkgs) package-activated-list))) (current-buffer)) - (let ((info-dirs (butlast Info-directory-list))) + (let ((info-dirs + (mapcar (lambda (info-dir) + (package--quickstart-relative package-quickstart-file info-dir)) + (butlast Info-directory-list)))) (when info-dirs (pp `(progn (require 'info) (info-initialize) -- 2.39.3 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 02 18:30:23 2025 Received: (at 77468) by debbugs.gnu.org; 2 Apr 2025 22:30:24 +0000 Received: from localhost ([127.0.0.1]:59911 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u06bH-00077i-Ft for submit@debbugs.gnu.org; Wed, 02 Apr 2025 18:30:23 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:39953) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u06bD-00076K-RU for 77468@debbugs.gnu.org; Wed, 02 Apr 2025 18:30:20 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 8EF9310004C; Wed, 2 Apr 2025 18:30:13 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1743633008; bh=miJRsJ1M1yVbyyNAoRRjJNJtR1NF2UeKv6IEIzKylBk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=DWur6RkKIjJaWTf3ITIBXrfJduwLU7I99Um1cntoc4/9sl3t0BwUkAnepi/szIlk5 yju6gNUu2hfgbm6H/yqEwf/easMAb3+9uAJHF5PBlpOzaa5wEugxHXzRjMvKvgk1EF LywDhsthnOkeypiH07mJYVivf5EiW1JPdW074NygLf9u2ivM0fe4g/wdRFisptSnEd Wn3jO/jcXsLd//loQexMg5XCaI6dP/LGoZPAS/hvgKCvBumDYAGB7VZQSyt+5JVd18 bVxUBMxiMfc9jENpIUcJGUZeEox15h6iqVtkwNnc9szdsh21irncxFnUUbiH3c+l3s J6UcSdlU/Deyg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 42606100029; Wed, 2 Apr 2025 18:30:08 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 259D2120227; Wed, 2 Apr 2025 18:30:08 -0400 (EDT) From: Stefan Monnier To: Spencer Baugh Subject: Re: bug#77468: 30.1.50; package-quickstart file is not relocatable In-Reply-To: Message-ID: References: Date: Wed, 02 Apr 2025 18:30:07 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.102 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77468 Cc: 77468@debbugs.gnu.org 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: -3.3 (---) > Makes sense. How about this? See comments below. > diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el > index b9a8dacab15..1269a9c95e7 100644 > --- a/lisp/emacs-lisp/package.el > +++ b/lisp/emacs-lisp/package.el > @@ -4591,6 +4591,14 @@ package--quickstart-maybe-refresh > (delete-file (concat package-quickstart-file "c")) > (delete-file package-quickstart-file))) > > +(defun package--quickstart-relative (load-name file) > + "Return an expression which evaluates to FILE while loading LOAD-NAME." > + (let* ((dir (file-name-directory (expand-file-name load-name))) > + (relname (file-relative-name file dir))) > + (if (string-prefix-p ".." relname) > + file > + `(file-name-concat (file-name-directory load-file-name) ,relname)))) I think I'd test "../" just in case of dirnames that start with "..". Also, could we compute (file-name-directory load-file-name) once at the beginning of the quickstart file instead of once per inlined file? > (defun package-quickstart-refresh () > "(Re)Generate the `package-quickstart-file'." > (interactive) > @@ -4605,7 +4613,8 @@ package-quickstart-refresh > ;; aren't truncated. > (print-length nil) > (print-level nil) > - (Info-directory-list '(""))) > + (Info-directory-list '("")) > + (qs-dir (file-name-directory (expand-file-name package-quickstart-file)))) AFAICT `qs-dir` is not used. > @@ -4622,7 +4631,7 @@ package-quickstart-refresh > ;; Prefer uncompiled files (and don't accept .so files). > (let ((load-suffixes '(".el" ".elc"))) > (locate-library (package--autoloads-file-name pkg)))) > - (pfile (prin1-to-string file))) > + (pfile (prin1-to-string (package--quickstart-relative package-quickstart-file file)))) > (insert "(let* ((load-file-name " pfile ")\ > \(load-true-file-name load-file-name))\n") > (insert-file-contents file) I think this needs wrapping to fit within 80 columns. > @@ -4638,7 +4647,10 @@ package-quickstart-refresh > (append ',(mapcar #'package-desc-name package--quickstart-pkgs) > package-activated-list))) > (current-buffer)) > - (let ((info-dirs (butlast Info-directory-list))) > + (let ((info-dirs > + (mapcar (lambda (info-dir) > + (package--quickstart-relative package-quickstart-file info-dir)) > + (butlast Info-directory-list)))) > (when info-dirs > (pp `(progn (require 'info) > (info-initialize) I think this won't work because the rest of the code does: (setq Info-directory-list (append ',info-dirs Info-directory-list))) so the `file-name-concat`s won't be evaluated. Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 03 01:16:49 2025 Received: (at 77468) by debbugs.gnu.org; 3 Apr 2025 05:16:49 +0000 Received: from localhost ([127.0.0.1]:60429 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u0Cwb-000669-1D for submit@debbugs.gnu.org; Thu, 03 Apr 2025 01:16:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40482) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u0CwZ-00065r-0u for 77468@debbugs.gnu.org; Thu, 03 Apr 2025 01:16:47 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u0CwS-0002cK-3p; Thu, 03 Apr 2025 01:16:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=aRFI4wc42etx1Xq8j0U16V46rOnnn2RLS4yOE2AeF2Y=; b=MtdvshL+o+9y p3fc5bxsJ/XE9hWLRZu6axezXVdTQbDYo3peQdZDY188yWxc+7D7yqjq+YihYeGPSSmyf4zTI4g7M 7tYFivjWXJaYmnOeFbuo1FKNGsTQpDPy5LGQWGxzNiOnqB+55s1EiQkOiG3HEM8LBKngPj+SboS0i jVMb/yuGbB1Wc9ILa9U+wtISk9avXd6H2pR8o1CEmy0DzwXauMZAdbIos0GV5upkAsvav6yHQHT+D q+0vdOcaB4QjmbF5nVVP2kvRKjswUgnepZN8UK+7L1ypL6CYJPiUaY+q3gwYhYNneJJmrfRDsBqAS iqGNAKLirkYrPx1J9TC74w==; Date: Thu, 03 Apr 2025 08:16:37 +0300 Message-Id: <861pu925ai.fsf@gnu.org> From: Eli Zaretskii To: Spencer Baugh In-Reply-To: (bug-gnu-emacs@gnu.org) Subject: Re: bug#77468: 30.1.50; package-quickstart file is not relocatable References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77468 Cc: monnier@iro.umontreal.ca, 77468@debbugs.gnu.org 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: -3.3 (---) > Cc: 77468@debbugs.gnu.org > Date: Wed, 02 Apr 2025 17:22:22 -0400 > From: Spencer Baugh via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Stefan Monnier writes: > >> Maybe package-quickstart.el could use relative names to packages in > >> package-user-dir (since it itself lives in package-user-dir), and > >> absolute names to packages outside that? > > > > Sounds OK. Tho maybe we should check `file*-in-directory-p` (or the > > presence of "../" in the output of `file-relative-name`) rather than > > distinguishing based on `package-user-dir` vs `package-directory-list`? > > > > In any case, it sounds like a good compromise. > > Makes sense. How about this? Thanks, but please always remember to comment such non-trivial code, explaining its purpose and the problems it attempts to solve. Otherwise we make Emacs much harder to maintain for those who come after us. From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 03 09:24:31 2025 Received: (at 77468) by debbugs.gnu.org; 3 Apr 2025 13:24:32 +0000 Received: from localhost ([127.0.0.1]:33332 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u0KYY-0001Ru-NP for submit@debbugs.gnu.org; Thu, 03 Apr 2025 09:24:31 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:47477) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u0KYT-0001Rd-IJ for 77468@debbugs.gnu.org; Thu, 03 Apr 2025 09:24:28 -0400 From: Spencer Baugh To: Stefan Monnier Subject: Re: bug#77468: 30.1.50; package-quickstart file is not relocatable In-Reply-To: (Stefan Monnier's message of "Wed, 02 Apr 2025 18:30:07 -0400") References: Date: Thu, 03 Apr 2025 09:24:19 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1743686659; bh=z0DKHF8/xswiFQpVbFG9ruI7cfm0cLKTl5O0X9ziqTQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=OGv6HUmXucBxQ7l6VwBDyZQ+GNOqObXphtXKpHZu3JTjrR7la/BSt6irfKklYRFxO eFuS18VHHaMZdkphjX96gfPx4cpugJEEzUrKvtIO0QXJ/e83VV4ZbxJRXwykI9WKBE rcWctFdajXTvnKPxFUAgE2TTlHEPtPZOCo8BwCoq0IYANcmSprLCvyWTQ//xwuSJZI jLqn5A979d5UvDiLHB+auNSgtx2xwjWgw/+uJSz8zNkbTDhGKDmZeqCZQfvuDdAa82 rP2FJ+GdmBgW3wZ8EjZCUEjW63QEeU5BDxB9ujtkmGCWwXc4PwhEDfCc8OixWIDjFW ohc2TKwyzeyAg== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77468 Cc: 77468@debbugs.gnu.org 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: -3.3 (---) --=-=-= Content-Type: text/plain Stefan Monnier writes: >> Makes sense. How about this? > > See comments below. > >> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el >> index b9a8dacab15..1269a9c95e7 100644 >> --- a/lisp/emacs-lisp/package.el >> +++ b/lisp/emacs-lisp/package.el >> @@ -4591,6 +4591,14 @@ package--quickstart-maybe-refresh >> (delete-file (concat package-quickstart-file "c")) >> (delete-file package-quickstart-file))) >> >> +(defun package--quickstart-relative (load-name file) >> + "Return an expression which evaluates to FILE while loading LOAD-NAME." >> + (let* ((dir (file-name-directory (expand-file-name load-name))) >> + (relname (file-relative-name file dir))) >> + (if (string-prefix-p ".." relname) >> + file >> + `(file-name-concat (file-name-directory load-file-name) ,relname)))) > > I think I'd test "../" just in case of dirnames that start with "..". Good catch... actually I think I should just use file-in-directory-p, that's more self-explanatory. > Also, could we compute (file-name-directory load-file-name) > once at the beginning of the quickstart file instead of once per > inlined file? Done. >> (defun package-quickstart-refresh () >> "(Re)Generate the `package-quickstart-file'." >> (interactive) >> @@ -4605,7 +4613,8 @@ package-quickstart-refresh >> ;; aren't truncated. >> (print-length nil) >> (print-level nil) >> - (Info-directory-list '(""))) >> + (Info-directory-list '("")) >> + (qs-dir (file-name-directory (expand-file-name package-quickstart-file)))) > > AFAICT `qs-dir` is not used. Fixed. >> @@ -4622,7 +4631,7 @@ package-quickstart-refresh >> ;; Prefer uncompiled files (and don't accept .so files). >> (let ((load-suffixes '(".el" ".elc"))) >> (locate-library (package--autoloads-file-name pkg)))) >> - (pfile (prin1-to-string file))) >> + (pfile (prin1-to-string (package--quickstart-relative package-quickstart-file file)))) >> (insert "(let* ((load-file-name " pfile ")\ >> \(load-true-file-name load-file-name))\n") >> (insert-file-contents file) > > I think this needs wrapping to fit within 80 columns. Fixed. >> @@ -4638,7 +4647,10 @@ package-quickstart-refresh >> (append ',(mapcar #'package-desc-name package--quickstart-pkgs) >> package-activated-list))) >> (current-buffer)) >> - (let ((info-dirs (butlast Info-directory-list))) >> + (let ((info-dirs >> + (mapcar (lambda (info-dir) >> + (package--quickstart-relative package-quickstart-file info-dir)) >> + (butlast Info-directory-list)))) >> (when info-dirs >> (pp `(progn (require 'info) >> (info-initialize) > > I think this won't work because the rest of the code does: > > (setq Info-directory-list > (append ',info-dirs Info-directory-list))) > > so the `file-name-concat`s won't be evaluated. Oops... I guess I didn't run info when testing this. Fixed. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Use-relative-names-where-possible-in-package-quickst.patch >From e25d657cbe01b6fb1162c17c8d344eff63621131 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Wed, 2 Apr 2025 17:21:24 -0400 Subject: [PATCH] Use relative names where possible in package-quickstart.el package-quickstart.el hardcodes many absolute file names, which makes it break if user-emacs-directory moves, or in other situations. To be slightly more robust to this, use relative file names to packages that are located in the same directory as package-quickstart.el. * lisp/emacs-lisp/package.el (package--quickstart-rel): Add. (package-quickstart-refresh): Use package--quickstart-rel on file names. (bug#77468) --- lisp/emacs-lisp/package.el | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index b9a8dacab15..a575dea7b92 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -4591,6 +4591,14 @@ package--quickstart-maybe-refresh (delete-file (concat package-quickstart-file "c")) (delete-file package-quickstart-file))) +(defun package--quickstart-rel (dir file) + "Return an expression which evaluates to FILE while loading a file in DIR." + (if (file-in-directory-p file dir) + ;; Use a relative name so we can still find FILE if DIR is moved. + `(file-name-concat (file-name-directory load-file-name) + ,(file-relative-name file dir)) + file)) + (defun package-quickstart-refresh () "(Re)Generate the `package-quickstart-file'." (interactive) @@ -4605,7 +4613,8 @@ package-quickstart-refresh ;; aren't truncated. (print-length nil) (print-level nil) - (Info-directory-list '(""))) + (Info-directory-list '("")) + (qs-dir (file-name-directory (expand-file-name package-quickstart-file)))) (dolist (elt package-alist) (condition-case err (package-activate (car elt)) @@ -4622,7 +4631,7 @@ package-quickstart-refresh ;; Prefer uncompiled files (and don't accept .so files). (let ((load-suffixes '(".el" ".elc"))) (locate-library (package--autoloads-file-name pkg)))) - (pfile (prin1-to-string file))) + (pfile (prin1-to-string (package--quickstart-rel qs-dir file)))) (insert "(let* ((load-file-name " pfile ")\ \(load-true-file-name load-file-name))\n") (insert-file-contents file) @@ -4638,12 +4647,15 @@ package-quickstart-refresh (append ',(mapcar #'package-desc-name package--quickstart-pkgs) package-activated-list))) (current-buffer)) - (let ((info-dirs (butlast Info-directory-list))) + (let ((info-dirs + (mapcar (lambda (info-dir) + (package--quickstart-rel qs-dir info-dir)) + (butlast Info-directory-list)))) (when info-dirs (pp `(progn (require 'info) (info-initialize) (setq Info-directory-list - (append ',info-dirs Info-directory-list))) + (append (list . ,info-dirs) Info-directory-list))) (current-buffer)))) ;; Use `\s' instead of a space character, so this code chunk is not ;; mistaken for an actual file-local section of package.el. -- 2.39.3 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 03 09:24:41 2025 Received: (at 77468) by debbugs.gnu.org; 3 Apr 2025 13:24:41 +0000 Received: from localhost ([127.0.0.1]:33336 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u0KYj-0001SJ-2B for submit@debbugs.gnu.org; Thu, 03 Apr 2025 09:24:41 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:37541) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u0KYg-0001S3-7e for 77468@debbugs.gnu.org; Thu, 03 Apr 2025 09:24:38 -0400 From: Spencer Baugh To: Eli Zaretskii Subject: Re: bug#77468: 30.1.50; package-quickstart file is not relocatable In-Reply-To: <861pu925ai.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 03 Apr 2025 08:16:37 +0300") References: <861pu925ai.fsf@gnu.org> Date: Thu, 03 Apr 2025 09:24:32 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1743686673; bh=9Y7bKPWj/8iPckKD64kBibLBgUSjLBhphSCcMCwEOA8=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=yqUXK73Ppol/Ti3Bghvhvm9nUGYRjY8WoalsImpdsqsskkdW/icfOtN/H3V3182ju ieDCy3X7K9SSR3zLaqgFnEdbkIlSxSVXhiRg+h7jGO4Bwi+yATVDDHp+xfqBnOUHZV sgCFiklGVhn7SwfjX/YzVhdJLyE8/AztFXB+prvzaVvi6LJRdsjPnuUg0Ldj78hNS9 gpBKDy5CDVChdwh12MwKfbs1YgEo2WvjNEK46eEiEsYefLpJ/1LDkdbkqQmPg7B0i0 F2iQGcHeu2I6vCJtadtwU2Z+EZuMKefqge/L61fGoRRxzOcekWtZQd9gfICM97zlQ+ 51H8HtsHSbedw== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77468 Cc: monnier@iro.umontreal.ca, 77468@debbugs.gnu.org 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: -3.3 (---) Eli Zaretskii writes: >> Cc: 77468@debbugs.gnu.org >> Date: Wed, 02 Apr 2025 17:22:22 -0400 >> From: Spencer Baugh via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> Stefan Monnier writes: >> >> Maybe package-quickstart.el could use relative names to packages in >> >> package-user-dir (since it itself lives in package-user-dir), and >> >> absolute names to packages outside that? >> > >> > Sounds OK. Tho maybe we should check `file*-in-directory-p` (or the >> > presence of "../" in the output of `file-relative-name`) rather than >> > distinguishing based on `package-user-dir` vs `package-directory-list`? >> > >> > In any case, it sounds like a good compromise. >> >> Makes sense. How about this? > > Thanks, but please always remember to comment such non-trivial code, > explaining its purpose and the problems it attempts to solve. > Otherwise we make Emacs much harder to maintain for those who come > after us. Added a comment in the new version. From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 04 18:54:45 2025 Received: (at 77468) by debbugs.gnu.org; 4 Apr 2025 22:54:45 +0000 Received: from localhost ([127.0.0.1]:40454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u0pvx-0007Ce-0s for submit@debbugs.gnu.org; Fri, 04 Apr 2025 18:54:45 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:16068) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u0pvs-0007Bx-VT for 77468@debbugs.gnu.org; Fri, 04 Apr 2025 18:54:41 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 888DB807E8; Fri, 4 Apr 2025 18:54:33 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1743807272; bh=VCad9TU3QwE6nKqhijWOgaTmetiyjcf4qkOHmdOWLCE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=gjSMMbuRSMj2a/Mkid6blw0qtX179OjfpZxBgZ9UHMhWmfJkoPYgyjRvH6Yy6Gjzd tel7oNyiCSgZ5D6kP1VNZthKnNf9zyFRHwQDARqS8Dfzbah3z4Ir4JqLLBNGHnn+Qc tFwEpKOfQulub6jmoa46A/xEZVOubIvZ+M5RIk4zg+kgYmyhzm1xLGpyrwLI6H3zbP lbCMvI2Q7T2SzCDPC8d+oesUiGIlbar/eA1AqmD1eJIGLqpNwtf/4uzg27r8JQs9ZW eLT5I9KNkdA9ol67AXmpz4RaEembjAtCKiayhoG04a0dBrvvna3foume8+r+tSPDQ0 9HeSX2VHJSJ6g== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5532C806EF; Fri, 4 Apr 2025 18:54:32 -0400 (EDT) Received: from pastel (unknown [104.247.242.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 2C6661202A0; Fri, 4 Apr 2025 18:54:32 -0400 (EDT) From: Stefan Monnier To: Spencer Baugh Subject: Re: bug#77468: 30.1.50; package-quickstart file is not relocatable In-Reply-To: Message-ID: References: Date: Fri, 04 Apr 2025 18:54:23 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.357 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77468 Cc: 77468@debbugs.gnu.org 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: -3.3 (---) >> Also, could we compute (file-name-directory load-file-name) >> once at the beginning of the quickstart file instead of once per >> inlined file? > Done. I don't see it: > +(defun package--quickstart-rel (dir file) > + "Return an expression which evaluates to FILE while loading a file in DIR." > + (if (file-in-directory-p file dir) > + ;; Use a relative name so we can still find FILE if DIR is moved. > + `(file-name-concat (file-name-directory load-file-name) > + ,(file-relative-name file dir)) > + file)) We still generate code that computes `(file-name-directory load-file-name)` N times, AFAICT. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 07 13:02:50 2025 Received: (at 77468) by debbugs.gnu.org; 7 Apr 2025 17:02:50 +0000 Received: from localhost ([127.0.0.1]:56623 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u1ps1-0006PU-Sn for submit@debbugs.gnu.org; Mon, 07 Apr 2025 13:02:50 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:56663) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u1prz-0006Ov-DO for 77468@debbugs.gnu.org; Mon, 07 Apr 2025 13:02:48 -0400 From: Spencer Baugh To: Stefan Monnier Subject: Re: bug#77468: 30.1.50; package-quickstart file is not relocatable In-Reply-To: (Stefan Monnier's message of "Fri, 04 Apr 2025 18:54:23 -0400") References: Date: Mon, 07 Apr 2025 13:02:41 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1744045361; bh=7fjZqHKBIIGurP8pkRpo5br3gRPyKx/5IAnAAe12gas=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=IkxfGOIcxCQ5HWsObCS0nDUThdE2Qf8TdzH2XSl5xVUVxCvukVSt1hSazzevpxx60 m8bCLCAcmF0U4kGMEoEx46oqsFmQT5dPyJuxi4P5ZhehMdyJl9I4UvXc+o426oyMqa r9iaORG5SDlYXjUslRMAaNAJBK65RX8iSn0jbimsWFne9mlH+dkeOQlu0+bfmt2Mmf n4RTlU/nbpbgvIDSnIdadKMda8hKDW5KNm3P2vKm+W1uSkEuK7OJfiRR6NxMLTHiT/ HfuK4dO1Aa4aoFvGczYQjDwDljtjg0aq6WUr1WSBLzddl9fLtV8WRWF2x8CWweziaC wx80+E7PP9TZQ== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77468 Cc: 77468@debbugs.gnu.org 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: -3.3 (---) Stefan Monnier writes: >>> Also, could we compute (file-name-directory load-file-name) >>> once at the beginning of the quickstart file instead of once per >>> inlined file? >> Done. > > I don't see it: > >> +(defun package--quickstart-rel (dir file) >> + "Return an expression which evaluates to FILE while loading a file in DIR." >> + (if (file-in-directory-p file dir) >> + ;; Use a relative name so we can still find FILE if DIR is moved. >> + `(file-name-concat (file-name-directory load-file-name) >> + ,(file-relative-name file dir)) >> + file)) > > We still generate code that computes `(file-name-directory > load-file-name)` N times, AFAICT. Oh, I misunderstood what you were asking for, I see now. I guess file-name-directory can be slow due to find-file-name-handler... that's sad since it's otherwise just a trivial string operation. I guess I could wrap the entire file in a let binding, but that's mildly annoying and ugly... How about putting the let binding outside the file? Like this: diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index b9a8dacab15..d65d3baa7fa 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -1699,7 +1699,10 @@ package-activate-all (let* ((elc (concat package-quickstart-file "c")) (qs (if (file-readable-p elc) elc (if (file-readable-p package-quickstart-file) - package-quickstart-file)))) + package-quickstart-file))) + (default-directory + ;; For expressions produced by `package--quickstart-rel'. + (file-name-directory (expand-file-name package-quickstart-file)))) ;; The quickstart file presumes that it has a blank slate, ;; so don't use it if we already activated some packages. (or (and qs (not (bound-and-true-p package-activated-list)) @@ -4591,6 +4594,16 @@ package--quickstart-maybe-refresh (delete-file (concat package-quickstart-file "c")) (delete-file package-quickstart-file))) +(defun package--quickstart-rel (file) + "Return an expression which evaluates to FILE. + +If FILE is in `default-directory', returns an expression that is +relative to `default-directory', so if that directory is moved we can +still find FILE." + (if (file-in-directory-p file default-directory) + `(file-name-concat default-directory ,(file-relative-name file)) + file)) + (defun package-quickstart-refresh () "(Re)Generate the `package-quickstart-file'." (interactive) @@ -4605,7 +4618,10 @@ package-quickstart-refresh ;; aren't truncated. (print-length nil) (print-level nil) - (Info-directory-list '(""))) + (Info-directory-list '("")) + (default-directory + ;; So `package--quickstart-rel' produces relative expressions. + (file-name-directory (expand-file-name package-quickstart-file)))) (dolist (elt package-alist) (condition-case err (package-activate (car elt)) @@ -4622,7 +4638,7 @@ package-quickstart-refresh ;; Prefer uncompiled files (and don't accept .so files). (let ((load-suffixes '(".el" ".elc"))) (locate-library (package--autoloads-file-name pkg)))) - (pfile (prin1-to-string file))) + (pfile (prin1-to-string (package--quickstart-rel file)))) (insert "(let* ((load-file-name " pfile ")\ \(load-true-file-name load-file-name))\n") (insert-file-contents file) @@ -4638,12 +4654,13 @@ package-quickstart-refresh (append ',(mapcar #'package-desc-name package--quickstart-pkgs) package-activated-list))) (current-buffer)) - (let ((info-dirs (butlast Info-directory-list))) + (let ((info-dirs + (mapcar #'package--quickstart-rel (butlast Info-directory-list)))) (when info-dirs (pp `(progn (require 'info) (info-initialize) (setq Info-directory-list - (append ',info-dirs Info-directory-list))) + (append (list . ,info-dirs) Info-directory-list))) (current-buffer)))) ;; Use `\s' instead of a space character, so this code chunk is not ;; mistaken for an actual file-local section of package.el. From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 07 13:11:03 2025 Received: (at 77468) by debbugs.gnu.org; 7 Apr 2025 17:11:03 +0000 Received: from localhost ([127.0.0.1]:56639 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u1pzz-00073Y-DN for submit@debbugs.gnu.org; Mon, 07 Apr 2025 13:11:03 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:16570) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u1pzw-00072i-CT for 77468@debbugs.gnu.org; Mon, 07 Apr 2025 13:11:01 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 0D5718085E; Mon, 7 Apr 2025 13:10:54 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1744045853; bh=/i8GfWglHPB5FdgSFDGZV2dJZL9o4DpRyHBh7XhowdU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=GKZzG1fpzREMnN4Lb7JWSzADyERTvHHkwmC8UA5TWd1YEpOi2iRc8nxXSZVM8Uj9E WjrSs0Cv+J7LjVIlwG12u9G5N05dXV+AOxzLEZtcCSGDxSdBQmn1jakQQgSBJo0bIh Z5OJ/lgukDpzTJwXE8PwZVqsRX6wyG74V5S44GFhw868J6yyIWR+56yjo4gAaTu2Fj eb0qJiYfa7a/LGvzYYFod5/HzLXsBKtK8pBYhNs/VLmIQ7+aXVXqsJC1/kVixBfuyA AXGjlbJpAu6h43/KYTMDsuMc4UtRS30ZuRkKFfsmfoCIOn+FsZ3HNf380twXQmimwA bnmLxyVUjypgQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 1C4DB803EA; Mon, 7 Apr 2025 13:10:53 -0400 (EDT) Received: from alfajor (modemcable005.21-80-70.mc.videotron.ca [70.80.21.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id F139E12022C; Mon, 7 Apr 2025 13:10:52 -0400 (EDT) From: Stefan Monnier To: Spencer Baugh Subject: Re: bug#77468: 30.1.50; package-quickstart file is not relocatable In-Reply-To: Message-ID: References: Date: Mon, 07 Apr 2025 13:10:52 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.153 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77468 Cc: 77468@debbugs.gnu.org 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: -3.3 (---) > I guess file-name-directory can be slow due to find-file-name-handler... > that's sad since it's otherwise just a trivial string operation. It's not a major performance issue, but I can't think of a reason why we wouldn't want to make this trivial optimization. > I guess I could wrap the entire file in a let binding, but that's mildly > annoying and ugly... We can just `setq` a private global var. It's conceptually ugly, but it gets the job done. As long as we support only a single global `package-quickstart.el` that should be good enough. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 07 13:30:05 2025 Received: (at 77468) by debbugs.gnu.org; 7 Apr 2025 17:30:05 +0000 Received: from localhost ([127.0.0.1]:56674 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u1qIO-0008Sx-EC for submit@debbugs.gnu.org; Mon, 07 Apr 2025 13:30:05 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:51021) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u1qIK-0008RE-9Z for 77468@debbugs.gnu.org; Mon, 07 Apr 2025 13:30:01 -0400 From: Spencer Baugh To: Stefan Monnier Subject: Re: bug#77468: 30.1.50; package-quickstart file is not relocatable In-Reply-To: (Stefan Monnier's message of "Mon, 07 Apr 2025 13:10:52 -0400") References: Date: Mon, 07 Apr 2025 13:29:54 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1744046994; bh=TwZZygJR7SVPocWYySZTy/1sN60X3rD3b99LCFcYaZw=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=uHSh3e/amiBJBjj0ynXFSLYQRgisouvYKs9F0/QI1nkqyFOLPdO0EXY7HBWOwydic pm6YM1u9n8sUpHo2Hw5N4STwzke/W7HVXbuq6aAKdT0xnWt6p2Rs/nv3dnDuewnEps g0YSzB7IA0bjHGXeydezSMhp0DrfS2mdWS8w7faY2g8AAtZkZbSUaHpV1MM8ad5umi mAXObx0uWpP4HR/21Fvup4GSAAIZFJ2NLJTnkNG6HXGErUvoVRXrT53sa7exyg060i 9mgn4lgD3wC1APJ7MpOCnIg98kZF54Bzj3I+HBgCHvu98d8fxlyqB09mB/Rfu6co3M UNSlk/Veg6P2Q== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77468 Cc: 77468@debbugs.gnu.org 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: -3.3 (---) Stefan Monnier writes: >> I guess file-name-directory can be slow due to find-file-name-handler... >> that's sad since it's otherwise just a trivial string operation. > > It's not a major performance issue, but I can't think of a reason why we > wouldn't want to make this trivial optimization. Agree, agreed. Just thinking about whether there's possibilities for further optimization (like, do we really need to have non-nil find-file-name-handler in the quickstart?). >> I guess I could wrap the entire file in a let binding, but that's mildly >> annoying and ugly... > > We can just `setq` a private global var. It's conceptually > ugly, but it gets the job done. As long as we support only a single > global `package-quickstart.el` that should be good enough. I guess you prefer this to the approach in the patch I sent, where I let-bind default-directory outside the load of package-quickstart-file? From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 07 13:32:11 2025 Received: (at 77468) by debbugs.gnu.org; 7 Apr 2025 17:32:11 +0000 Received: from localhost ([127.0.0.1]:56689 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u1qKQ-0000GN-Ju for submit@debbugs.gnu.org; Mon, 07 Apr 2025 13:32:11 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:43467) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u1qKM-0000FG-1k for 77468@debbugs.gnu.org; Mon, 07 Apr 2025 13:32:07 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id B83B110006B; Mon, 7 Apr 2025 13:32:00 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1744047120; bh=H8kdv2wvdjhe7PvQPSHAMmNTrQRC7sfN+vHYWn6QkQM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Rg2XRN9i5971QUMAe3Vq/NnISeoVVWMcvLKRODAscnyXoXZNaFFTIdAXDjPcsqvUq oEDoCyRBJ4i7pLLC2jlmagrLR/NAQisdhVckB/8z0jkGr3ktOXLLwShyIzEeuJN8xD 6KukUGrJVULLWGGtazjVtj08lkRn9oPvZZJJ50rkGAsdHef73PaGYqLKeMc5peShVm 37byeiJFmjm8OLxGLGeV2Yd9zsoLv/6ejIgbbisEP/07eUV8VjjoMswqSQq1YIoChA rYIoQbDJRG4eoJzKKQVegme8sONh9piyGGxQrWZssyrLOyH9J0ZGP764XWaKlDa/gW iF2EKbnUgH7cQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 1D4EE100027; Mon, 7 Apr 2025 13:32:00 -0400 (EDT) Received: from alfajor (modemcable005.21-80-70.mc.videotron.ca [70.80.21.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id F0E911204E6; Mon, 7 Apr 2025 13:31:59 -0400 (EDT) From: Stefan Monnier To: Spencer Baugh Subject: Re: bug#77468: 30.1.50; package-quickstart file is not relocatable In-Reply-To: Message-ID: References: Date: Mon, 07 Apr 2025 13:31:59 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.308 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77468 Cc: 77468@debbugs.gnu.org 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: -3.3 (---) >> We can just `setq` a private global var. It's conceptually >> ugly, but it gets the job done. As long as we support only a single >> global `package-quickstart.el` that should be good enough. > I guess you prefer this to the approach in the patch I sent, where I > let-bind default-directory outside the load of package-quickstart-file? Your approach is cleaner but I'm just worried that someone out there loads the package-quickstart file "by hand". Maybe we can do both (and emit a warning if the `setq` is not redundant)? Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 08 14:30:44 2025 Received: (at 77468) by debbugs.gnu.org; 8 Apr 2025 18:30:44 +0000 Received: from localhost ([127.0.0.1]:35431 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u2Did-0004Q2-GS for submit@debbugs.gnu.org; Tue, 08 Apr 2025 14:30:43 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:53715) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u2DiS-0004P6-Op for 77468@debbugs.gnu.org; Tue, 08 Apr 2025 14:30:34 -0400 From: Spencer Baugh To: Stefan Monnier Subject: Re: bug#77468: 30.1.50; package-quickstart file is not relocatable In-Reply-To: (Stefan Monnier's message of "Mon, 07 Apr 2025 13:31:59 -0400") References: Date: Tue, 08 Apr 2025 14:30:26 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1744137026; bh=QlPvzpCkB9UnSkX0Mb4l831ftFephWh4zmDpZIpmR5o=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=qvlHWTy/1xlv6dEwRvs8A4kVpmsg/QNagMiEQmzlJrRpAsPYMZM6w1egA0OgvSTiR WifrLA8Qbm8e9SYWYFejygOIUdH2PjEhMfUmfybq8ij5+5N+3Ioi2hGNQphvWhcKpA W40WTCT02PZLEA4lj5gIiv8ZqP0D4oU/VXRYJG+QWf/yeyXCi24N5SgnDBNa/kL3yf uRMMWe7yEf6MaPCJKjHkRm6lVkHPctwMZASKGHK7i06srMauSR9ugs0zh0xp/bBt8l QSuw5otaXy8XNmK6oN24wTjMhRhIdhov3orjOHm1G8XEm6cH9e+j4Q9fswmLqgjp4K rtzMmmixsj7iQ== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77468 Cc: 77468@debbugs.gnu.org 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: -3.3 (---) --=-=-= Content-Type: text/plain Stefan Monnier writes: >>> We can just `setq` a private global var. It's conceptually >>> ugly, but it gets the job done. As long as we support only a single >>> global `package-quickstart.el` that should be good enough. >> I guess you prefer this to the approach in the patch I sent, where I >> let-bind default-directory outside the load of package-quickstart-file? > > Your approach is cleaner but I'm just worried that someone out there > loads the package-quickstart file "by hand". Ah, good point. I'll just do the setq, see patch: --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-Use-relative-names-where-possible-in-package-quickst.patch Content-Transfer-Encoding: quoted-printable >From 4699b39c629433e295988a1695261ce3d56400ea Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Wed, 2 Apr 2025 17:21:24 -0400 Subject: [PATCH] Use relative names where possible in package-quickstart.el package-quickstart.el hardcodes many absolute file names, which makes it break if user-emacs-directory moves, or in other situations. To be slightly more robust to this, use relative file names to packages that are located in the same directory as package-quickstart.el. * lisp/emacs-lisp/package.el (package--quickstart-dir, package--quickstart-rel): Add. (package-quickstart-refresh): Use package--quickstart-rel on file names. (bug#77468) --- lisp/emacs-lisp/package.el | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index b9a8dacab15..bec44a6b637 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -4591,6 +4591,19 @@ package--quickstart-maybe-refresh (delete-file (concat package-quickstart-file "c")) (delete-file package-quickstart-file))) =20 +(defvar package--quickstart-dir nil + "Set by `package-quickstart-file' to the directory containing it.") + +(defun package--quickstart-rel (file) + "Return an expr depending on `package--quickstart-dir' which evaluates t= o FILE. + +If FILE is in `package--quickstart-dir', returns an expression that is +relative to that directory, so if that directory is moved we can still +find FILE." + (if (file-in-directory-p file package--quickstart-dir) + `(file-name-concat package--quickstart-dir ,(file-relative-name file= package--quickstart-dir)) + file)) + (defun package-quickstart-refresh () "(Re)Generate the `package-quickstart-file'." (interactive) @@ -4605,7 +4618,8 @@ package-quickstart-refresh ;; aren't truncated. (print-length nil) (print-level nil) - (Info-directory-list '(""))) + (Info-directory-list '("")) + (package--quickstart-dir nil)) (dolist (elt package-alist) (condition-case err (package-activate (car elt)) @@ -4617,12 +4631,16 @@ package-quickstart-refresh (emacs-lisp-mode) ;For `syntax-ppss'. (insert ";;; Quickstart file to activate all packages at startup -*= - lexical-binding:t -*-\n") (insert ";; =C2=A1=C2=A1 This file is autogenerated by `package-quic= kstart-refresh', DO NOT EDIT !!\n\n") + (setq package--quickstart-dir + (file-name-directory (expand-file-name package-quickstart-file= ))) + (insert (pp '(setq package--quickstart-dir + (file-name-directory (expand-file-name load-file-= name))))) (dolist (pkg package--quickstart-pkgs) (let* ((file ;; Prefer uncompiled files (and don't accept .so files). (let ((load-suffixes '(".el" ".elc"))) (locate-library (package--autoloads-file-name pkg)))) - (pfile (prin1-to-string file))) + (pfile (prin1-to-string (package--quickstart-rel file)))) (insert "(let* ((load-file-name " pfile ")\ \(load-true-file-name load-file-name))\n") (insert-file-contents file) @@ -4638,12 +4656,13 @@ package-quickstart-refresh (append ',(mapcar #'package-desc-name package--quickstar= t-pkgs) package-activated-list))) (current-buffer)) - (let ((info-dirs (butlast Info-directory-list))) + (let ((info-dirs + (mapcar #'package--quickstart-rel (butlast Info-directory-lis= t)))) (when info-dirs (pp `(progn (require 'info) (info-initialize) (setq Info-directory-list - (append ',info-dirs Info-directory-list))) + (append (list . ,info-dirs) Info-directory-lis= t))) (current-buffer)))) ;; Use `\s' instead of a space character, so this code chunk is not ;; mistaken for an actual file-local section of package.el. --=20 2.39.3 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 08 14:40:57 2025 Received: (at 77468-done) by debbugs.gnu.org; 8 Apr 2025 18:40:57 +0000 Received: from localhost ([127.0.0.1]:35467 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u2DsX-0004wE-2n for submit@debbugs.gnu.org; Tue, 08 Apr 2025 14:40:57 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:19562) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u2DsT-0004vu-KO for 77468-done@debbugs.gnu.org; Tue, 08 Apr 2025 14:40:54 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 21E86442934; Tue, 8 Apr 2025 14:40:48 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1744137647; bh=Id/Kj+yDS+qEMBg4HQ82OQbnzMUgQ4ja05gueur4ZP8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=oaa03RflSnJHlU/MQ939hx3RmbvaIqUO6RRverk+vFv2/ShsbG8gohzgW0OwOM8wj ETb3wZr+LZs+TCsFKEkWjiW++m4g9oWzJ70OB640yBptBG5v53gmEod185rfLrWLz+ hAKPr4ANT0I4WDn7OK+sPOYe8+FjZa5BzD6wj+NepjuTGwEPR7hcyGnrXFpe3deGof rjA7xtbF7rUIPd+qhnpJp4ajmwm697uFEfIXEVrBCFcwwkPpX0bHbzfYuiNHKi+VsV c1VLDKBEDiNy45VEVSvYOI9fxAXXBFku5MRu7vapMz0icy5it2fHXJQBjz4WwhhJTu hE8wzst02D3eQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 498CF442745; Tue, 8 Apr 2025 14:40:47 -0400 (EDT) Received: from pastel (unknown [104.247.242.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1EA721206D6; Tue, 8 Apr 2025 14:40:47 -0400 (EDT) From: Stefan Monnier To: Spencer Baugh Subject: Re: bug#77468: 30.1.50; package-quickstart file is not relocatable In-Reply-To: Message-ID: References: Date: Tue, 08 Apr 2025 14:40:46 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.368 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77468-done Cc: 77468-done@debbugs.gnu.org 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: -3.3 (---) >> Your approach is cleaner but I'm just worried that someone out there >> loads the package-quickstart file "by hand". > > Ah, good point. I'll just do the setq, see patch: Thanks, pushed to `master`, Stefan From unknown Sun Aug 17 09:10:30 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 07 May 2025 11:24:22 +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