Closed winny- closed 1 year ago
I have the same issue with Magit and disabling Forge temporarily fixed it. I only have the issue on MacOS, but I don't have it on Linux.
I am guessing that there was some fatal error when running the executable. That causes the process sentinel to be run and that kills the process buffer unconditionally, which in this case is premature because emacsql-waiting-p
will still try to access the buffer.
Changing that function to the following should address that:
(cl-defmethod emacsql-waiting-p ((connection emacsql-protocol-mixin))
"Return t if the end of the buffer has a properly-formatted prompt.
Also return t if the process has terminated."
(let ((buffer (emacsql-buffer connection)))
(or (not (buffer-live-p buffer))
(with-current-buffer buffer
(and (>= (buffer-size) 2)
(string= "#\n"
(buffer-substring (- (point-max) 2) (point-max))))))))
However, that won't show the error message about why the executable could not be run. (You probably will get an error about a timeout, but that probably isn't correct, given that you didn't mention a hang.) The process sentinel should probably be changed to raise an error itself, but I don't know what such an error would look like, so please also apply this patch:
diff --git a/emacsql-sqlite.el b/emacsql-sqlite.el
index b14d1ac..58f2f5a 100644
--- a/emacsql-sqlite.el
+++ b/emacsql-sqlite.el
@@ -96,7 +96,11 @@ (cl-defmethod initialize-instance :after
"emacsql-sqlite" buffer emacsql-sqlite-executable fullfile)))
(setf (slot-value connection 'process) process)
(setf (process-sentinel process)
- (lambda (proc _) (kill-buffer (process-buffer proc))))
+ (lambda (proc str)
+ (let ((buf (process-buffer proc)))
+ (message "--- %s" str)
+ (message ">>>%s<<<" (with-current-buffer buf (buffer-string)))
+ (kill-buffer buf))))
(emacsql-wait connection)
(emacsql connection [:pragma (= busy-timeout $s1)]
(/ (* emacsql-global-timeout 1000) 2))
and post the output.
I just came across this using emacs HEAD (a06c13db9eee0487975177089b44198dd08206be) and saw some "Selecting deleted buffer" messages which led me to this bug. it does appear to be related to sqlite.
Emacs 28 (the version I can get easily from Debian) works without a problem.
My minimal init.el
to reproduce this is:
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el"
user-emacs-directory))
(bootstrap-version 5)
(straight-url (concat "https://raw.githubusercontent.com/raxod502/"
"straight.el/develop/install.el")))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously straight-url
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(message (concat "got " bootstrap-file))
(load bootstrap-file nil 'nomessage))
(declare-function straight-use-package (expand-file-name "~/.emacs.d/straight/repos/straight.el/straight.el"))
(straight-use-package 'use-package)
(use-package magit
:bind (("C-x v d" . magit-status))
:ensure t
:init
(fset 'vc-dir 'magit-status)
:custom
(magit-diff-refine-hunk t)
(magit-diff-refine-ignore-whitespace t)
; maybe change to a numger if this is too heavy
(magit-diff-adjust-tab-width t))
(use-package forge
:straight t
:after magit)
Bug report on the emacs side: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60872
what behavior you expected
Magit should able to carry on and open the buffer if there's a forge issue.
what behavior you observed
Visitng a file in a git repository, then running
magit-status
yields an error.and how we can reproduce the issue.
Not sure, see the next section for my environment information. If I'm successful in reproducing in an easy-to-reproduce enviroment I'll follow up.
Environment
backtrace
other issues with same error message (might be unrelated)