copilot.el
copilot.el copied to clipboard
Cannot start copilot due to wrong `copilot--base-dir`.
I have been getting difficulties getting copilot to start for a week or two. I have emacs installed via snap on Ubuntu 22.04 and here is a minimal init.el:
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(require 'package)
(setq package-archives '(("elpa" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")))
(package-initialize)
(use-package editorconfig
:ensure t)
(use-package jsonrpc
:ensure t)
(use-package copilot
:straight (:host github :repo "copilot-emacs/copilot.el" :files ("*.el"))
:ensure t)
And here is the error I get in *Messages* when I run M-x copilot mode
Copilot agent started.
[jsonrpc] Server exited with status 1
jsonrpc-request: jsonrpc-error: "request id=1 failed:", (jsonrpc-error-code . -1), (jsonrpc-error-message . "Server died"), (jsonrpc-error-data)
Copilot agent started.
[jsonrpc] Server exited with status 1
Error during redisplay: (copilot--on-doc-focus #<window 7 on *scratch*>) signaled (jsonrpc-error "request id=1 failed:" (jsonrpc-error-code . -1) (jsonrpc-error-message . "Server died") (jsonrpc-error-data))
After seeing that copilot had difficulties finding an agent.js, I managed to get it running by adding the following to my configuration:
:config
(setq copilot--base-dir "/home/ren/.emacs.d/straight/repos/copilot.el/")
Is there a bug in how copilot--base-dir is set, or is something missing in the README installation instructions, or is something wrong with my system?
I'm facing a somewhat similar problem. The *copilot events* buffer shows the error below. And indeed it looks for the installation in the wrong path, as running copilot-install-server executes
/opt/homebrew/bin/npm -g --prefix /Users/shmulikregev/.emacs.d/.cache/copilot install copilot-node-server\@1.31.0
which installs to /Users/shmulikregev/.emacs.d/.cache/copilot/lib/node_modules/copilot-node-server .
I'm using the latest (at the time of writing) revision (733bff26) and a development version of emacs 30.0.50 . Worth noting, it was working perfectly and for some reason, without any explicit updates on my part, stopped.
Any help would be appreciated (it is somewhat surprising how I got accustomed to using it).
[stderr] node:internal/modules/cjs/loader:1145
[stderr] throw err;
[stderr] ^
[stderr]
[stderr] Error: Cannot find module '/Users/shmulikregev/.emacs.d/.cache/copilot/bin/copilot-node-server'
[stderr] at Module._resolveFilename (node:internal/modules/cjs/loader:1142:15)
[stderr] at Module._load (node:internal/modules/cjs/loader:983:27)
[stderr] at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12)
[stderr] at node:internal/main/run_main_module:28:49 {
[stderr] code: 'MODULE_NOT_FOUND',
[stderr] requireStack: []
[stderr] }
[stderr]
[stderr] Node.js v21.7.1
update - for what it is worth 7a45181f does not have this problem.