GNU bug report logs - #70526
29.2; package-vc-upgrade failed with error message "File is not under version control"

Previous Next

Package: emacs;

Reported by: "Yi Yue" <include_yy <at> qq.com>

Date: Tue, 23 Apr 2024 05:16:02 UTC

Severity: normal

Found in version 29.2

Done: Philip Kaludercic <philipk <at> posteo.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Philip Kaludercic <philipk <at> posteo.net>
To: "Yi Yue" <include_yy <at> qq.com>
Cc: 70526 <at> debbugs.gnu.org
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 part 1 (text/plain, inline)]
"Yi Yue" <include_yy <at> qq.com> 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")
> &nbsp; error("File is not under version control")
> &nbsp; vc-deduce-fileset-1(t nil nil)
> &nbsp; vc-deduce-fileset(t)
> &nbsp; vc-pull()
> &nbsp; ......
>
>
> 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)
> &nbsp; (defun yy/package-vc-upgrade-advice (upfun pkg-desc)
> &nbsp; &nbsp; (with-temp-buffer
> &nbsp; &nbsp; &nbsp; (funcall upfun pkg-desc)))
> &nbsp; (advice-add 'package-vc-upgrade :around 'yy/package-vc-upgrade-advice))

Injecting this into package-vc, we get:

[Message part 2 (text/plain, 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."
[Message part 3 (text/plain, inline)]
(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

This bug report was last modified 1 year and 24 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.