Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copilot--on-doc-close attempts to start the copilot agent, failing on tramp #265

Open
offbyone opened this issue Feb 17, 2024 · 2 comments

Comments

@offbyone
Copy link

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)
@WarFox
Copy link

WarFox commented Feb 17, 2024

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

@jkl1337
Copy link
Contributor

jkl1337 commented Feb 18, 2024

@offbyone This appears a duplicate of #261 and #262, and fixed in main. Please update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants