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

lsp-bridge-copilot-login 无法登录 #924

Closed
vinurs opened this issue Apr 28, 2024 · 30 comments
Closed

lsp-bridge-copilot-login 无法登录 #924

vinurs opened this issue Apr 28, 2024 · 30 comments
Labels
help wanted Extra attention is needed

Comments

@vinurs
Copy link

vinurs commented Apr 28, 2024

CleanShot 2024-04-29 at 06 00 10@2x
Emacs用的是 6dcd7de02aa1671f6aa56f7a754b63e809ca8c99 这个commit编译的,这两天才编译的,yasnippet 跟 lsp-bridge都是用的最新的commit
最小化的配置是

(setq debug-on-error t)

(add-to-list 'load-path "~/.emacs.d/markdown-mode")

(add-to-list 'load-path "~/.emacs.d/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)

(add-to-list 'load-path "~/.emacs.d/lsp-bridge")

(require 'yasnippet)
(yas-global-mode 1)

(require 'lsp-bridge)
(setq lsp-bridge-enable-log t)

(global-lsp-bridge-mode)

执行 lsp-bridge-copilot-login会报下面的错误

Eval in Emacs: (lsp-bridge--first-start '60289)

--- [06:00:54.694922] Send initialize request (33932) to 'copilot' for project copilot_backend
{
   "id": 33932,
   "method": "initialize",
   "params": {
      "capabilities": {
         "workspace": {
            "workspaceFolders": true
         }
      }
   },
   "message_type": "request",
   "jsonrpc": "2.0"
}

--- [06:00:54.695094] Send setEditorInfo request (22200) to 'copilot' for project copilot_backend
{
   "id": 22200,
   "method": "setEditorInfo",
   "params": {
      "editorInfo": {
         "name": "Emacs",
         "version": "28.0"
      },
      "editorPluginInfo": {
         "name": "lsp-bridge",
         "version": "0.0.1"
      },
      "networkProxy": false
   },
   "message_type": "request",
   "jsonrpc": "2.0"
}

--- [06:00:54.695156] Send signInInitiate request (42432) to 'copilot' for project copilot_backend
{
   "id": 42432,
   "method": "signInInitiate",
   "params": {
      "dummy": "signInInitiate"
   },
   "message_type": "request",
   "jsonrpc": "2.0"
}
ERROR:epc:KeyError('result')
ERROR:epc:Unexpected error
Traceback (most recent call last):
  File "/Users/vinurs/.pyenv/versions/3.11.4/lib/python3.11/site-packages/epc/handler.py", line 242, in _handle
    reply = handler(uid, *args)
            ^^^^^^^^^^^^^^^^^^^
  File "/Users/vinurs/.pyenv/versions/3.11.4/lib/python3.11/site-packages/epc/utils.py", line 51, in new_method
    ret = method(self, *args, **kwds)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/vinurs/.pyenv/versions/3.11.4/lib/python3.11/site-packages/epc/handler.py", line 265, in _handle_call
    return ['return', uid, func(*args)]
                           ^^^^^^^^^^^
  File "/Users/vinurs/.emacs.d/lsp-bridge/lsp_bridge.py", line 812, in copilot_login
    self.copilot.login()
  File "/Users/vinurs/sys-cfg/.emacs.q/lsp-bridge/core/copilot.py", line 249, in login
    result = self.wait_response['result']
             ~~~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 'result'

@manateelazycat
Copy link
Owner

@kongds Can you help review this issue ? Thanks. ;)

@kongds
Copy link
Contributor

kongds commented Apr 29, 2024

可能是没法访问github的关系,我这边可以正常登录。可以用proxy试试

@manateelazycat
Copy link
Owner

我已经在README加入了代理说明, 感谢大佬

@vinurs
Copy link
Author

vinurs commented Apr 29, 2024

有其它的方法确认不?因为我的Emacs里面是有代理相关的配置的

(setq url-gateway-method 'socks)
(setq url-proxy-services
      '(("http"     . "127.0.0.1:7890")
       ("https"     . "127.0.0.1:7890")))
(setq socks-server '("Default server" "127.0.0.1" 7890 5))

然后我用 eww 访问了一下 google是可以的
CleanShot 2024-04-29 at 13 31 54@2x

@kongds
Copy link
Contributor

kongds commented Apr 29, 2024

因该需要用lsp-bridge的这个参数acm-backend-copilot-network-proxy来设置,具体可以看帮助

或者用setenv也行

(setenv "https_proxy" "http://127.0.0.1:7890")
(setenv "http_proxy" "http://127.0.0.1:7890") 

@vinurs
Copy link
Author

vinurs commented Apr 29, 2024

我直接这样尝试设置了一下,还是不行

(setenv "https_proxy" "http://127.0.0.1:7890")
(setenv "http_proxy" "http://127.0.0.1:7890")
(setq acm-backend-copilot-network-proxy '(:host "127.0.0.1" :port 7890))

这个问题也是最近才出现的,我之前一直用的好好的,配置啥的都没变过

@kongds
Copy link
Contributor

kongds commented Apr 29, 2024

这个的设置应该需要restart lsp-bridge才会生效,可以在(lsp-bridge-restart-process)之后试试

@vinurs
Copy link
Author

vinurs commented Apr 29, 2024

试了一下,还是不行,同样的报错

@manateelazycat
Copy link
Owner

试了一下,还是不行,同样的报错

你是不是代理不靠谱啊。 ;)

@vinurs
Copy link
Author

vinurs commented Apr 29, 2024

试了一下,还是不行,同样的报错

你是不是代理不靠谱啊。 ;)

这个我也无法确认靠谱不靠谱,我访问其它的都蛮正常的

@manateelazycat
Copy link
Owner

试了一下,还是不行,同样的报错

你是不是代理不靠谱啊。 ;)

这个我也无法确认靠谱不靠谱,我访问其它的都蛮正常的

github 和 ssh 的代理一般都需要好的代理, 我自己的代理, 美国的就没法 git push, 但是日本的服务器就可以了, 建议多多切换一下代理服务器, 最好用透明代理。

@vinurs
Copy link
Author

vinurs commented Apr 29, 2024

我安装了一下 vscode,然后在里面安装了一下 copilot 的插件,然后连接了我的github的账号,我看是可以补全的,这是不是可以排除我网络的问题了?
CleanShot 2024-04-29 at 15 19 37@2x

@manateelazycat
Copy link
Owner

不能确定啊, 我平常不用 copilot 插件

@vinurs
Copy link
Author

vinurs commented May 2, 2024

CleanShot 2024-05-03 at 05 36 32@2x
我下载了一个gh命令行,然后在命令行下面是可以登录 copilot 的

@vinurs
Copy link
Author

vinurs commented May 2, 2024

@kongds 我看日志里面有这个,这是表示没有走代理么?
CleanShot 2024-05-03 at 05 51 46@2x

@manateelazycat
Copy link
Owner

@vinurs 你的系统是配置的全局透明代理吗?

@vinurs
Copy link
Author

vinurs commented May 3, 2024

@manateelazycat 对的,我用的clashx pro,然出站模式是选的 按照规则 来进行判断

@manateelazycat
Copy link
Owner

@vinurs 我感觉是代理配置的问题哈, 暂时关闭issue, 如果有新的线索欢迎 re-open 这个issue, 或者发送PR, 感谢反馈

@vinurs
Copy link
Author

vinurs commented May 5, 2024

diff --git a/core/copilot.py b/core/copilot.py
index a63c2c8..fead47a 100644
--- a/core/copilot.py
+++ b/core/copilot.py
@@ -246,6 +246,9 @@ class Copilot:
         self.sender.send_request('signInInitiate', {'dummy': "signInInitiate"}, self.wait_id)
         while self.wait_id is not None:
             time.sleep(0.1)
+
+        log_time(self.wait_response)
+
         result = self.wait_response['result']
         if result['status'] == 'AlreadySignedIn':
             message_emacs(f'Already signed in as {result["user"]}')

我在这里加了一句打印语句,错误原因如下,但是我不知道该如何继续调试下去了,大佬指点一下

--- [09:05:10.190130] {'jsonrpc': '2.0', 'id': 8238, 'error': {'code': -32002, 'message': 'Agent service not initialized.'}}

@manateelazycat
Copy link
Owner

你付费了吗?我记得这个是要付费的

@manateelazycat manateelazycat reopened this May 5, 2024
@vinurs
Copy link
Author

vinurs commented May 5, 2024

你这么一问我想起来,我之前的账号没有续费,换了一个账号续费的,难道本地还有啥记录什么的?

@manateelazycat
Copy link
Owner

不知道呀, 以前也有朋友调试了半天登录不上去, 发现是没有付费导致的。

@manateelazycat manateelazycat added the help wanted Extra attention is needed label May 7, 2024
@vinurs
Copy link
Author

vinurs commented May 15, 2024

CleanShot 2024-05-15 at 17 28 24@2x
https://github.com/copilot-emacs/copilot.el
我试了一下这个插件,是可以正常登录的

@manateelazycat
Copy link
Owner

@vinurs 大佬, 看着是 lsp-bridge 的bug, 能帮忙提交一个补丁吗? 我没有买 copilot

@CnsMaple
Copy link
Contributor

Same problem and none of the ai assistants are available in Windows, super problematic!

@manateelazycat
Copy link
Owner

I don't use copilot, please help to send PR

@vinurs
Copy link
Author

vinurs commented May 26, 2024

抱歉,前段时间一直忙别的事情,这个就暂时搁置了
今天晚上有空就看了一下这个问题,目前先查出了一个原因:那就是 copilot-node-server 版本的问题,我一般比较喜欢用最新的库,因此我安装的时候

npm install -g copilot-node-server

我对比了一下 lsp-bridge 跟 copilot.el 这两个插件发送给 copilot 的参数,我发现差别不大;但是 copilot.el 会在 emacs 的配置目录下面自己安装一个 copilot-node-server ,因此我就试着在 lsp-bridge里面就直接用这个库来进行启动,成功了^_^

而 copilot.el 里面默认用的版本是 1.14.0,现在我换回了 1.14.0,已经可以正常使用了

npm install -g copilot-node-server@1.14.0

CleanShot 2024-05-27 at 00 56 45@2x
目前用最新的库的话,在这一步会失败,原因我暂时也还没不知道

        editor_info = {'editorInfo': {'name': 'Emacs', 'version': '28.0'},
                       'editorPluginInfo': {'name': 'lsp-bridge', 'version': '0.0.1'},
                       'networkProxy': epc_arg_transformer(self.proxy)}
        self.sender.send_request('setEditorInfo', editor_info, generate_request_id())

这段代码之后,我把接收到的信息打印出来,就是下面的这段

--- [00:09:56.906998] {'jsonrpc': '2.0', 'id': 49309, 'error': {'code': -32002, 'message': 'Agent service not initialized.'}}

@vinurs
Copy link
Author

vinurs commented May 26, 2024

稍微验证了一下,从 copilot-node-server@1.28.0 就不行了

@manateelazycat
Copy link
Owner

能否改代码,我们现在固定在某个版本,等以后再升级?

@manateelazycat
Copy link
Owner

我暂时推送了一个补丁到README 82a6f1e

避免这个问题坑到更多人

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants