copilot-emacs / copilot.el

An unofficial Copilot plugin for Emacs.
MIT License
1.79k stars 126 forks source link

"Process copilot agent not running: killed: 9\n" #97

Closed benthamite closed 1 year ago

benthamite commented 1 year ago

Copilot stopped working after I rebuilt all my packages (it was working fine before). If copilot-mode mode is enabled, whenever it attempts to suggest a completion I get a "Process copilot agent not running: killed: 9\n" error (backtrace appended).

copilot-diagnose results in the same error.

Running node /path/to/package/dist/agent.js produces this:

Content-Length: 232

{"jsonrpc":"2.0","method":"LogMessage","params":{"level":0,"message":"[DEBUG] [agent] [2023-03-04T22:25:37.275Z] Agent service starting","metadataStr":"[DEBUG] [agent] [2023-03-04T22:25:37.275Z]","extra":["Agent service starting"]}}

Any idea what might be going on?

(use-package copilot
  :straight (:host github :repo "zerolfx/copilot.el" :files ("dist" "*.el"))

  :custom
  (copilot-node-executable "/opt/homebrew/opt/node/bin/node")

  :hook
  (prog-mode-hook . copilot-mode)

  :general
  (copilot-mode-map
   "M-<tab>" 'copilot-accept-completion
   "A-M-<tab>" 'copilot-accept-completion-by-line))

macOS Ventura 13.2.1 (22D68) GNU Emacs 30.0.50 (build 1, aarch64-apple-darwin22.1.0, NS appkit-2299.00 Version 13.0.1 (Build 22A400)) of 2023-02-23 Node.js v18.14.2

Debugger entered--Lisp error: (error "Process copilot agent not running: killed: 9\n")
  process-send-string(#<process copilot agent> "Content-Length: 1859\15\n\15\n{\"jsonrpc\":\"2.0\",\"id\":6,\"m...")
  #f(compiled-function (arg1 &rest rest) "Send MESSAGE, a JSON object, to CONNECTION." #<bytecode 0x19cce2e840bb5a9a>)(#<jsonrpc-process-connection jsonrpc-process-connection-5e90ad1a> :id 6 :method getCompletions :params (:doc (:source "Afters rebuilding all my packages, I am unable to ..." :tabSize 4 :indentSize 4 :insertSpaces :json-false :path nil :uri "" :relativePath "" :languageId "gfm" :position (:line 0 :character 149))))
  apply(#f(compiled-function (arg1 &rest rest) "Send MESSAGE, a JSON object, to CONNECTION." #<bytecode 0x19cce2e840bb5a9a>) #<jsonrpc-process-connection jsonrpc-process-connection-5e90ad1a> (:id 6 :method getCompletions :params (:doc (:source "Afters rebuilding all my packages, I am unable to ..." :tabSize 4 :indentSize 4 :insertSpaces :json-false :path nil :uri "" :relativePath "" :languageId "gfm" :position (:line 0 :character 149)))))
  jsonrpc-connection-send(#<jsonrpc-process-connection jsonrpc-process-connection-5e90ad1a> :id 6 :method getCompletions :params (:doc (:source "Afters rebuilding all my packages, I am unable to ..." :tabSize 4 :indentSize 4 :insertSpaces :json-false :path nil :uri "" :relativePath "" :languageId "gfm" :position (:line 0 :character 149))))
  jsonrpc--async-request-1(#<jsonrpc-process-connection jsonrpc-process-connection-5e90ad1a> getCompletions (:doc (:source "Afters rebuilding all my packages, I am unable to ..." :tabSize 4 :indentSize 4 :insertSpaces :json-false :path nil :uri "" :relativePath "" :languageId "gfm" :position (:line 0 :character 149))) :success-fn #f(compiled-function (result) #<bytecode 0x9f652db715f3eef>) :success-fn #f(compiled-function (jsonrpc-lambda-elem0) #<bytecode 0x1a0becda7751f652>))
  jsonrpc-async-request(#<jsonrpc-process-connection jsonrpc-process-connection-5e90ad1a> getCompletions (:doc (:source "Afters rebuilding all my packages, I am unable to ..." :tabSize 4 :indentSize 4 :insertSpaces :json-false :path nil :uri "" :relativePath "" :languageId "gfm" :position (:line 0 :character 149))) :success-fn #f(compiled-function (result) #<bytecode 0x9f652db715f3eef>) :success-fn #f(compiled-function (jsonrpc-lambda-elem0) #<bytecode 0x1a0becda7751f652>))
  copilot--get-completion(#f(compiled-function (jsonrpc-lambda-elem0) #<bytecode 0x1a0becda7751f652>))
  copilot-complete()
  copilot--post-command-debounce(#<buffer New Issue · zerolfx/copilot.el<2>>)
  apply(copilot--post-command-debounce #<buffer New Issue · zerolfx/copilot.el<2>>)
  timer-event-handler([t 0 0 0 nil copilot--post-command-debounce (#<buffer New Issue · zerolfx/copilot.el<2>>) idle 0 nil])

zerolfx commented 1 year ago

I just merged #88 as a potential fix.

benthamite commented 1 year ago

Thanks. The commit didn't fix it, but the error is now different:

Debugger entered--Lisp error: (invalid-function (buf (current-buffer)))
  (buf (current-buffer))()
  copilot--get-completion(#f(compiled-function (jsonrpc-lambda-elem0) #<bytecode 0x1a0becdd23ece852>))
  copilot-complete()
  copilot--post-command-debounce(#<buffer *scratch*>)
  apply(copilot--post-command-debounce #<buffer *scratch*>)
  timer-event-handler([t 0 0 0 nil copilot--post-command-debounce (#<buffer *scratch*>) idle 0 nil])

It looks like something with the lexical-let declaration in the copilot--async-request macro.

madsroskar commented 1 year ago

error: (invalid-function (buf (current-buffer)))

I'm also encountering this error.

MacOS Ventura 13.2.1 (22D68) GNU Emacs 28.2 (build 1, aarch64-apple-darwin20.6.0, Carbon Version 164 AppKit 2202.7) of 2023-02-03 Node v18.14.1

Changing the lexical-let to just let gets it working for me, but I don't know enough to know if that has any consequences I don't see.

zerolfx commented 1 year ago

I should validate the PR before merging it.

I have reverted that commit and re-upgraded agent.js. @benthamite Please check it again.

benthamite commented 1 year ago

Thanks. Alas, no luck:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p t)
  jsonrpc--log-event(#<jsonrpc-process-connection jsonrpc-process-connection-a7fb3c72> (:jsonrpc "2.0" :id 2 :method "getCompletions" :params (:doc (:source "(use-package copilot\n  :straight (:host github :re..." :tabSize 8 :indentSize 8 :insertSpaces :json-false :path nil :uri "" :relativePath "" :languageId "emacs-lisp" :position (:line 14 :character 1)))) client)
  #f(compiled-function (arg1 &rest rest) "Send MESSAGE, a JSON object, to CONNECTION." #<bytecode 0x19c9e711dce5fcda>)(#<jsonrpc-process-connection jsonrpc-process-connection-a7fb3c72> :id 2 :method getCompletions :params (:doc (:source "(use-package copilot\n  :straight (:host github :re..." :tabSize 8 :indentSize 8 :insertSpaces :json-false :path nil :uri "" :relativePath "" :languageId "emacs-lisp" :position (:line 14 :character 1))))
  apply(#f(compiled-function (arg1 &rest rest) "Send MESSAGE, a JSON object, to CONNECTION." #<bytecode 0x19c9e711dce5fcda>) #<jsonrpc-process-connection jsonrpc-process-connection-a7fb3c72> (:id 2 :method getCompletions :params (:doc (:source "(use-package copilot\n  :straight (:host github :re..." :tabSize 8 :indentSize 8 :insertSpaces :json-false :path nil :uri "" :relativePath "" :languageId "emacs-lisp" :position (:line 14 :character 1)))))
  jsonrpc-connection-send(#<jsonrpc-process-connection jsonrpc-process-connection-a7fb3c72> :id 2 :method getCompletions :params (:doc (:source "(use-package copilot\n  :straight (:host github :re..." :tabSize 8 :indentSize 8 :insertSpaces :json-false :path nil :uri "" :relativePath "" :languageId "emacs-lisp" :position (:line 14 :character 1))))
  jsonrpc--async-request-1(#<jsonrpc-process-connection jsonrpc-process-connection-a7fb3c72> getCompletions (:doc (:source "(use-package copilot\n  :straight (:host github :re..." :tabSize 8 :indentSize 8 :insertSpaces :json-false :path nil :uri "" :relativePath "" :languageId "emacs-lisp" :position (:line 14 :character 1))) :success-fn #f(compiled-function (result) #<bytecode 0x9f65cc1c10b6eef>) :success-fn #f(compiled-function (jsonrpc-lambda-elem0) #<bytecode 0x1a0becdd23ece852>))
  jsonrpc-async-request(#<jsonrpc-process-connection jsonrpc-process-connection-a7fb3c72> getCompletions (:doc (:source "(use-package copilot\n  :straight (:host github :re..." :tabSize 8 :indentSize 8 :insertSpaces :json-false :path nil :uri "" :relativePath "" :languageId "emacs-lisp" :position (:line 14 :character 1))) :success-fn #f(compiled-function (result) #<bytecode 0x9f65cc1c10b6eef>) :success-fn #f(compiled-function (jsonrpc-lambda-elem0) #<bytecode 0x1a0becdd23ece852>))
  copilot--get-completion(#f(compiled-function (jsonrpc-lambda-elem0) #<bytecode 0x1a0becdd23ece852>))
  copilot-complete()
  copilot--post-command-debounce(#<buffer config.org (org src)>)
  apply(copilot--post-command-debounce #<buffer config.org (org src)>)
  timer-event-handler([t 0 0 0 nil copilot--post-command-debounce (#<buffer config.org (org src)>) idle 0 nil])
zerolfx commented 1 year ago

@benthamite Take a look at #70, and check the variable named copilot-log-max.

benthamite commented 1 year ago

Setting copilot-log-max to 1000 fixed it. Thank you for the help, and for the great package!