copilot-emacs / copilot.el

An unofficial Copilot plugin for Emacs.
MIT License
1.74k stars 124 forks source link

BUG - copilot login for the first time, does not reconize node update up to 16+ #152

Closed Jhonathan-Pedroso closed 1 year ago

Jhonathan-Pedroso commented 1 year ago

I am trying to setup copilot for the first in my emacs v28.1. After adding the elisp code ~/.emacs.d/myinit.org, evaluating the code block, and next attempting to execute the step M-x copilot-login, it display the error message:

user-error: Node 16+ is required but found 12.22 [2 times]

In the first occurrence of the error, I checked and indeed was the case of under version; but even after I updated to the version v16.20.1; it still persist displaying the error.

My guess: It seems some global variable was set, and its state pointing the version or the executable was not updated; persisting triggering the error even after the update. Probably, something related to the variable copilot-node-executable, that it is not properly captured after the updated during the M-x copilot-login step.

My workaround:

I did the following after the elisp code that was to setup copilot:

(setq copilot-node-executable "<my-base-path>/.nvm/versions/node/v16.20.1/bin/node")

This is working for me.

Maybe adding in the readme.md documentation this step, or fixing the copilot.el would be a nice idea for others avoiding this bug. I hope the issue helps! Thanks in facilitating this awesome tool in emacs, great job!

zerolfx commented 1 year ago

The default value of copilot-node-executable is either node or node.exe, depending on the platform. It is used to directly locate the node executable, as shown in this link: https://github.com/zerolfx/copilot.el/blob/9694981880b9fed7ced4ccff4e60fc072290c9a4/copilot.el#L142.

Therefore, the behavior you described seems strange because nothing should be cached. I suggest evaluating (locate-file "node" exec-path) and (call-process "node" nil standard-output nil "--version")) in your Emacs to find out the reason.

I will update the readme to include copilot-node-executable in the setup instructions.