From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#70526: 29.2; package-vc-upgrade failed with error message "File is not under version control" Date: Tue, 23 Apr 2024 08:31:49 +0000 Message-ID: <875xw8pjii.fsf@posteo.net> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20572"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70526@debbugs.gnu.org To: "Yi Yue" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 23 10:33: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 1rzBaN-000557-6p for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 23 Apr 2024 10:33:07 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzBa6-0005aY-Kk; Tue, 23 Apr 2024 04:32:50 -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 1rzBa3-0005aH-TK for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2024 04:32:48 -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 1rzBa3-0007S5-K2 for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2024 04:32:47 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rzBaJ-00052I-Fi for bug-gnu-emacs@gnu.org; Tue, 23 Apr 2024 04:33:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Apr 2024 08:33:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70526 X-GNU-PR-Package: emacs Original-Received: via spool by 70526-submit@debbugs.gnu.org id=B70526.171386114118930 (code B ref 70526); Tue, 23 Apr 2024 08:33:03 +0000 Original-Received: (at 70526) by debbugs.gnu.org; 23 Apr 2024 08:32:21 +0000 Original-Received: from localhost ([127.0.0.1]:50750 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzBZb-0004v0-DC for submit@debbugs.gnu.org; Tue, 23 Apr 2024 04:32:20 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:56047) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzBZV-0004tJ-JE for 70526@debbugs.gnu.org; Tue, 23 Apr 2024 04:32:17 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id CC6B4240027 for <70526@debbugs.gnu.org>; Tue, 23 Apr 2024 10:31:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1713861110; bh=9M7PGwLQB05S8AinGewSAF7k/EIVSQLUWvwahm7XS1U=; h=From:To:Cc:Subject:OpenPGP:Date:Message-ID:MIME-Version: Content-Type:From; b=pkaMDr2gpdPexJKwH9maky9oI1gXpNFN03eK9GtIGm1tSD02pKR/QVnhBfDUom2uG daDb5k/xyVDJxPXXstZqDEF4umOSKr+3E/0tWm7rphTvbCqU4muxV7t6lC8HO0GQiB /djrehBOpWjOLe9ElcWsArh7f8iSeHXU0DkiZl3YsrNnlRzFL1/iKDkO96A9BA7Gfo YHYkLyXfrILBgkXF23AF0gUyJJBnCF6aYI6sm5VHB1FGKZd9wlUjFtEyKpgPQT4EXb wed9plvRipB8/wvZx8bmwagnBmzsJPGMaBSQmRlziL9zb/LJYXlbsiZfA/PmJWgIa5 gMxFN/6oXnZvA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VNwMV0xVRz9rxK; Tue, 23 Apr 2024 10:31:49 +0200 (CEST) In-Reply-To: (Yi Yue's message of "Tue, 23 Apr 2024 10:51:18 +0900") OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66; url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66"; preference=signencrypt 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:283874 Archived-At: --=-=-= Content-Type: text/plain "Yi Yue" writes: > Hi all: > > > I encountered the following Backtrace information when invoking > `package-vc-upgrade'. > > > Debugger entered--Lisp error: (error "File is not under version control") >   error("File is not under version control") >   vc-deduce-fileset-1(t nil nil) >   vc-deduce-fileset(t) >   vc-pull() >   ...... > > > After some edebug debugging and reading the source code, I found that > this error occurs if the buffer where `package-vc-upgrade' is called is > not under a git repository. Additionally, if the current buffer of the > command invocation does not correspond to a specific file, then the > command can execute normally. > > > After reading the implementation of `package-vc-upgrade', I found that it > binds `default-directory' to the package's path. However, the internally > called `vc-pull' function, which uses `vc-deduce-fileset-1', first > utilizes `buffer-file-name' instead of `default-directory' to fetch > version control backend related information, which leads to this error. > > > In my past usage, I did not encounter this error, probably because I > usually invoked it within a file buffer under a git repository, or used > the command in a buffer provided by `list-packages'. Here is one > solution I used: > > > (when (eq emacs-major-version 29) >   (defun yy/package-vc-upgrade-advice (upfun pkg-desc) >     (with-temp-buffer >       (funcall upfun pkg-desc))) >   (advice-add 'package-vc-upgrade :around 'yy/package-vc-upgrade-advice)) Injecting this into package-vc, we get: --=-=-= Content-Type: text/plain Content-Disposition: inline diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index ef056c7909b..4e88964ecd0 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -810,8 +810,9 @@ package-vc-upgrade (remove-hook 'vc-post-command-functions post-upgrade)))))) (add-hook 'vc-post-command-functions post-upgrade) (with-demoted-errors "Failed to fetch: %S" - (let ((default-directory pkg-dir)) - (vc-pull))))) + (with-temp-buffer + (let ((default-directory pkg-dir)) + (vc-pull)))))) (defun package-vc--archives-initialize () "Initialize package.el and fetch package specifications." --=-=-= Content-Type: text/plain (or alternatively just binding buffer-file-name to nil after default-directory). but it feels like the fix should happen in vc.el, by being able to communicate that we the file set should be derived from the default directory, and the current file should be ignored... > In a minimal environment with emacs -Q, the following steps can > reproduce my issue: > > > ;; a simple package by purcell > (package-vc-install "https://github.com/purcell/unfill") > ;; then try to upgrade it in a buffer that buffer-file-name is not nil > ;; and the file is not under Git version control system. > M-x package-vc-upgrade unfill RET > ;; now the error may occurs > > > Regards > > > YI YUE -- Philip Kaludercic on peregrine --=-=-=--