copilot--on-doc-close attempts to start the copilot agent, failing on tramp
I'm trying to close a buffer on a tramp connection, in a file format that has copilot-mode enabled. This actually blocks me killing the buffer, since the process tries to start the copilot agent on the remote:
Debugger entered--Lisp error: (wrong-type-argument package-desc nil)
signal(wrong-type-argument (package-desc nil))
(or (progn (and (memq (type-of desc) cl-struct-package-desc-tags) t)) (signal 'wrong-type-argument (list 'package-desc desc)))
(progn (or (progn (and (memq (type-of desc) cl-struct-package-desc-tags) t)) (signal 'wrong-type-argument (list 'package-desc desc))) (aref desc 2))
(let* ((desc (package-get-descriptor 'jsonrpc)) (vlist (progn (or (progn (and (memq ... cl-struct-package-desc-tags) t)) (signal 'wrong-type-argument (list 'package-desc desc))) (aref desc 2))) (version (package-version-join vlist))) version)
copilot--jsonrpc-version()
(version< (copilot--jsonrpc-version) "1.0.23")
(let ((node-version (string-to-number (s-chop-prefix "v" (s-trim (let (...) (unwind-protect ... ...)))))) (old-jsonrpc (version< (copilot--jsonrpc-version) "1.0.23"))) (cond ((< node-version 18) (user-error "Node 18+ is required but found %s" node-version)) (t (setq copilot--connection (make-instance 'jsonrpc-process-connection :name "copilot" (if old-jsonrpc :events-buffer-scrollback-size :events-buffer-config) (if old-jsonrpc copilot-log-max (list ':size copilot-log-max)) :notification-dispatcher #'copilot--handle-notification :process (make-process :name "copilot agent" :command (list copilot-node-executable (concat copilot--base-dir "/dist/agent.js")) :coding 'utf-8-emacs-unix :connection-type 'pipe :stderr (get-buffer-create "*copilot stderr*") :noquery t))) (message "Copilot agent started.") (progn (if (copilot--connection-alivep) nil (copilot--start-agent)) (jsonrpc-request copilot--connection 'initialize '(:capabilities (:workspace ...)))) (progn (if (copilot--connection-alivep) nil (copilot--start-agent)) (let ((buf (current-buffer))) (jsonrpc-async-request copilot--connection 'setEditorInfo (cons ':editorInfo (cons ... ...)) :success-fn #'(lambda ... ...)))))))
(if (not (locate-file copilot-node-executable exec-path)) (user-error "Could not find node executable") (let ((node-version (string-to-number (s-chop-prefix "v" (s-trim (let ... ...))))) (old-jsonrpc (version< (copilot--jsonrpc-version) "1.0.23"))) (cond ((< node-version 18) (user-error "Node 18+ is required but found %s" node-version)) (t (setq copilot--connection (make-instance 'jsonrpc-process-connection :name "copilot" (if old-jsonrpc :events-buffer-scrollback-size :events-buffer-config) (if old-jsonrpc copilot-log-max (list ... copilot-log-max)) :notification-dispatcher #'copilot--handle-notification :process (make-process :name "copilot agent" :command (list copilot-node-executable ...) :coding 'utf-8-emacs-unix :connection-type 'pipe :stderr (get-buffer-create "*copilot stderr*") :noquery t))) (message "Copilot agent started.") (progn (if (copilot--connection-alivep) nil (copilot--start-agent)) (jsonrpc-request copilot--connection 'initialize '(:capabilities ...))) (progn (if (copilot--connection-alivep) nil (copilot--start-agent)) (let ((buf ...)) (jsonrpc-async-request copilot--connection 'setEditorInfo (cons ... ...) :success-fn #'...)))))))
copilot--start-agent()
(if (copilot--connection-alivep) nil (copilot--start-agent))
(progn (if (copilot--connection-alivep) nil (copilot--start-agent)) (jsonrpc-notify copilot--connection 'textDocument/didClose (list :textDocument (list :uri (copilot--get-uri)))))
(progn (progn (if (copilot--connection-alivep) nil (copilot--start-agent)) (jsonrpc-notify copilot--connection 'textDocument/didClose (list :textDocument (list :uri (copilot--get-uri))))) (setq copilot--opened-buffers (delete (current-buffer) copilot--opened-buffers)))
(if (-contains-p copilot--opened-buffers (current-buffer)) (progn (progn (if (copilot--connection-alivep) nil (copilot--start-agent)) (jsonrpc-notify copilot--connection 'textDocument/didClose (list :textDocument (list :uri (copilot--get-uri))))) (setq copilot--opened-buffers (delete (current-buffer) copilot--opened-buffers))))
copilot--on-doc-close()
kill-buffer(".logs.env")
funcall-interactively(kill-buffer ".logs.env")
command-execute(kill-buffer)
I am getting a similar error based on package-desc
Debugger entered--Lisp error: (wrong-type-argument package-desc nil)
package-desc-version(nil)
copilot--jsonrpc-version()
copilot--start-agent()
copilot--get-completion(#f(compiled-function (jsonrpc-lambda-elem1) #<bytecode 0xcf9a27f4d604b18>))
copilot-complete()
copilot--post-command-debounce(#<buffer warmacs-vcs.el>)
apply(copilot--post-command-debounce #<buffer warmacs-vcs.el>)
timer-event-handler([t 0 0 0 nil copilot--post-command-debounce (#<buffer warmacs-vcs.el>) idle 0 nil])
Further investigation, copilot--jsonrpc-version function calls package-get-descriptor like the following
(defun copilot--jsonrpc-version ()
"Return the jsonrpc version."
(let* ((desc (package-get-descriptor 'jsonrpc))
(vlist (package-desc-version desc))
(version (package-version-join vlist)))
version))
On my emacs version 30.1, (package-get-descriptor 'jsonrpc) is returning nil, which in turn causes package-desc-version to be called with nil
I had nuked my emacs packages earlier today and reinstalled everything. Noticed this problem after that
@offbyone This appears a duplicate of #261 and #262, and fixed in main. Please update.