copilot-emacs / copilot.el

An unofficial Copilot plugin for Emacs.
MIT License
1.71k stars 122 forks source link

Latest commit (f8283e4) causes runtime exception: (wrong-type-argument package-desc nil) #261

Closed rnadler closed 4 months ago

rnadler commented 4 months ago

Emacs 29.2 node v19.4.0 Pin to commit 581cadd to resolve.

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("packages.el")
  funcall-interactively(kill-buffer "packages.el")
  command-execute(kill-buffer)
jcs090218 commented 4 months ago

Sorry about this. I've opened the fix in #260.

rnadler commented 4 months ago

No more errors, but I noticed that after copilot starts a file buffer containing jsonrpc/jsonrpc.el is opened. I don't believe this was happening before. I can close it manually, but this seems undesirable.

jcs090218 commented 4 months ago

Thank you for the report! I've updated the code!