sublime-treesitter / TreeSitter

Sublime Text Tree-sitter configuration and abstraction layer
MIT License
19 stars 1 forks source link

Seems plugin fails if dependencies are not yet installed. #1

Closed deathaxe closed 7 months ago

deathaxe commented 8 months ago

I'd expect newly installed TreeSitter to install dependencies automatically.

Instead it only raises following exception.

Traceback (most recent call last):
  File "C:\Apps\Sublime Text 40xx\Data\Packages\TreeSitter\src\core.py", line 538, in cb
    parse_view(self.parser, view, s)
  File "C:\Apps\Sublime Text 40xx\Data\Packages\TreeSitter\src\core.py", line 529, in parser
    from tree_sitter import Parser
ModuleNotFoundError: No module named 'tree_sitter'
kaste commented 7 months ago

You first need to edit the settings and fill in the python path. Python 3.8 is already old and I had to install that version first (I used rye. Unfortuantely I couldn't use rye in the plugin's folder because Sublime locked some files and I couldn't use rye sync so I had to install python to a separate dir.). Then restart Sublime. Then you also need a C++ compiler. On Windows for each subprocess.run a cmd window pops up. The typical

STARTUPINFO = None
if sys.platform == "win32":
    STARTUPINFO = subprocess.STARTUPINFO()
    STARTUPINFO.dwFlags |= subprocess.STARTF_USESHOWWINDOW

must be set startupinfo=STARTUPINFO to hide that.

It is likely that compiling fails (e.g. you don't have the c compiler installed). Then it should also print the error message or generally stdout to the console. Right now it only prints that the command had a non-zero exit status.

The plugin works after that. 🌞

deathaxe commented 7 months ago

In that case this issue is a blocker for adding it to package control channel.

Plugins should not have such external dependencies, especially as it is not always easy to have multiple python versions on linux without hazzle of setting them up manually.

This would be poor UX for ST.

kaste commented 7 months ago

I also commented on package control. For the actual installation, if we could e.g. make it work with rye (rye is cross-platform and easy to install) it would be already way easier as rye grabs old python versions and can keep them separate from everything else.

kylebebak commented 7 months ago

This is closed by this release: https://github.com/sublime-treesitter/TreeSitter/releases/tag/1.1.0

STS now bundles tree_sitter and tree_sitter_languages as dependencies. Setting python_path is no longer required. Thanks deathaxe and kaste

See more context here: https://github.com/wbond/package_control_channel/pull/8862#issuecomment-1916027470