TerminalFi / LSP-copilot

GitHub Copilot support for Sublime Text LSP plugin provided through Copilot.vim.
625 stars 25 forks source link

Unable to see Copilot: Sign in on command palette #123

Closed aimanyusra closed 6 months ago

aimanyusra commented 9 months ago

Hi, I'm having issues loading copilot after installing it using Package Control. Below is what I can see with ST trying to load the plugin.

reloading python 3.3 plugin LSP-copilot.boot
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 308, in reload_plugin
    m = importlib.import_module(modulename)
  File "./python3.3/importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Installed Packages/LSP-copilot.sublime-package/boot.py", line 12, in <module>
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Installed Packages/LSP-copilot.sublime-package/plugin/__init__.py", line 1, in <module>
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Installed Packages/LSP-copilot.sublime-package/plugin/commands.py", line 20, in <module>
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Installed Packages/LSP-copilot.sublime-package/plugin/plugin.py", line 12, in <module>
  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Lib/python33/lsp_utils/__init__.py", line 6, in <module>
    from .generic_client_handler import GenericClientHandler
  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Lib/python33/lsp_utils/generic_client_handler.py", line 9, in <module>
    from package_control import events  # type: ignore
ImportError: cannot import name events

Is this an issue with python or something? I have other packages installed and they seem to be loading fine though

Below is also a screenshot of what happens when I type Copilot on the command palette Screenshot 2023-09-29 at 7 37 28 PM

aimanyusra commented 9 months ago

Additional logging included below (just scrolled down after I posted this)

Traceback (most recent call last):
  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Installed Packages/LSP.sublime-package/plugin/core/windows.py", line 479, in _update_panel_main_thread
    panel.run_command("lsp_update_panel", {"characters": characters})
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 1380, in run_command
    sublime_api.view_run_command(self.view_id, cmd, args)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1490, in run_
    self.view.end_edit(edit)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 1341, in end_edit
    sublime_api.view_end_edit(self.view_id, edit.edit_token)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 924, in on_modified
    run_view_callbacks('on_modified', view_id)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 708, in run_view_callbacks
    callback(v, *args)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 152, in profiler
    return event_handler(*args)
  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Packages/SublimeCodeIntel/SublimeCodeIntel.py", line 1439, in on_modified
    sublime_scope = getSublimeScope(view)
  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Packages/SublimeCodeIntel/SublimeCodeIntel.py", line 391, in getSublimeScope
    sel = view_sel[0]
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 1072, in __getitem__
    raise IndexError()
IndexError
Traceback (most recent call last):
  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Installed Packages/LSP.sublime-package/plugin/core/windows.py", line 479, in _update_panel_main_thread
    panel.run_command("lsp_update_panel", {"characters": characters})
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 1380, in run_command
    sublime_api.view_run_command(self.view_id, cmd, args)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 1490, in run_
    self.view.end_edit(edit)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 1341, in end_edit
    sublime_api.view_end_edit(self.view_id, edit.edit_token)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 932, in on_selection_modified
    run_view_callbacks('on_selection_modified', view_id)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 708, in run_view_callbacks
    callback(v, *args)
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 152, in profiler
    return event_handler(*args)
  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Packages/SublimeCodeIntel/SublimeCodeIntel.py", line 1520, in on_selection_modified
    rowcol = view.rowcol(view_sel[0].end())
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 1072, in __getitem__
    raise IndexError()
IndexError
TerminalFi commented 9 months ago

These are issues with LSP and SublimeCodeIntel and lsp_utils most likely

  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Lib/python33/lsp_utils/__init__.py", line 6, in <module>
    from .generic_client_handler import GenericClientHandler
  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Lib/python33/lsp_utils/generic_client_handler.py", line 9, in <module>
    from package_control import events  # type: ignore
ImportError: cannot import name events
  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Installed Packages/LSP.sublime-package/plugin/core/windows.py", line 479, in _update_panel_main_thread
    panel.run_command("lsp_update_panel", {"characters": characters})
  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Packages/SublimeCodeIntel/SublimeCodeIntel.py", line 1439, in on_modified
    sublime_scope = getSublimeScope(view)
  File "/Users/AIMAN.YUSRA/Library/Application Support/Sublime Text/Packages/SublimeCodeIntel/SublimeCodeIntel.py", line 391, in getSublimeScope
    sel = view_sel[0]
aimanyusra commented 9 months ago

@TerminalFi I'll try to remove the offending packages and reinstalling them, to see how it goes

TerminalFi commented 9 months ago

@TerminalFi I'll try to remove the offending packages and reinstalling them, to see how it goes

How did it go?

aimanyusra commented 8 months ago

@TerminalFi I'll try to remove the offending packages and reinstalling them, to see how it goes

How did it go?

No dice, tried removing the offending packages and tried to reinstall everything from scratch didn't work as well. Will keep looking for other solutions in the mean time.

TerminalFi commented 8 months ago

Having error logs does help. In case they are different. Does any other LSP-* package work?

jfcherng commented 8 months ago

What's the result of executing from package_control import events in your python 3.3 ST console?

image

akirk commented 8 months ago

I also ran into this and it is very likely to be related to upgrading Package Control to version 4 (beta) which seems to be necessary to get Package Control working again in Sublime Text and recent macOS versions.

While only a bandaid, you can get it to work again by commenting out three lines in ~/Library/Application Support/Sublime Text/Lib/python33/lsp_utils:

--- generic_client_handler.py
+++ generic_client_handler.py
@@ -6,7 +6,7 @@
 from LSP.plugin import DottedDict
 from LSP.plugin import WorkspaceFolder
 from LSP.plugin.core.typing import Any, Dict, List, Optional, Tuple
-from package_control import events  # type: ignore
+#from package_control import events  # type: ignore
 import os
 import shutil
 import sublime
@@ -46,8 +46,8 @@

             if os.path.isdir(cls.package_storage()):
                 shutil.rmtree(cls.package_storage())

-        if events.remove(cls.package_name):
-            sublime.set_timeout_async(run_async, 1000)
+        #if events.remove(cls.package_name):
+        #    sublime.set_timeout_async(run_async, 1000)
         super().cleanup()

     @classmethod

As far as I understand it, the above change only removes an async call to run_async if the lsp-copilot package is being uninstalled, so for normal operation it should be fine.

The new Package Control source is in https://github.com/wbond/package_control/blob/four-point-oh, likely there is a better way to solve this.

rchl commented 8 months ago

It's likely an issue with wrongly named Package Control package.

@akirk can you list the directory contents of your ~/Library/Application Support/Sublime Text/Installed Packages/?

akirk commented 8 months ago

I would not say that. I purposefully replaced Package Control.sublime-package with the 4.0 version because otherwise Package Control would not work. There is only one entry related to Package Control:

-rw-r--r--@  1 alex  staff   509K Oct 20 07:27 Package Control.sublime-package
rchl commented 8 months ago

Yeah, that looks right. By default there is a dot instead of space in name when downloading from github so I thought that's the problem.

And BTW you are sure that it's a latest version?

deathaxe commented 8 months ago

Some explation about causes is given in https://github.com/wbond/package_control/issues/1656.

For those being effected can you please try the following 2 things, just to make sure the problem still exists in latest available PC4.0-beta8 release?

  1. check, whether you really have PC4.0-beta8 installed. There were some nitpicks, which may cause older builds not being updated automatically once installed manually due to malformed version info.
  2. delete ~/Library/Application Support/Sublime Text/Libs/python33/package_control.py and that for python38 as well and restart ST (maybe twice) so PC recreates them with latest release. (should happen automatically, but just to be sure).

With the technical reason for that issue in mind, lsp_utils could work around it by not importing the module globally, but by following https://packagecontrol.io/docs/events and import it locally in GenericClientHandler.cleanup() method. This would ensure import taking place not before all packages have been loaded.

tristan-pv01 commented 6 months ago

Experiencing the same issue here; commenting out the lines that @akirk mentioned, except in the file Library/Application Support/Sublime Text/Lib/python33/lsp_utils/generic_client_handler.py, fixed the issue for me.

aimanyusra commented 6 months ago

I recently ran an update for ST and was required to update node as well, fixed the issue for me. I honestly can't remember any steps to replicate because I wasn't expecting it to fix the issue lol