"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: