teal-language-server icon indicating copy to clipboard operation
teal-language-server copied to clipboard

Please specify requirements in README

Open thomdin opened this issue 6 months ago • 4 comments

It seems tree-sitter-cli is a requirement, and I found out that the version in the ubuntu repos is too old. I ended up installing tree-sitter via cargo


Error after running `luarocks install teal-language-server` without tree-sitter-cli:
teal-language-server 0.1.1-1 depends on ltreesitter-ts 0.0.1 (not installed)
Installing https://luarocks.org/ltreesitter-ts-0.0.1-1.src.rock

gcc -O2 -fPIC -I/usr/include/lua5.1 -c ltreesitter/csrc/dynamiclib.c -o ltreesitter/csrc/dynamiclib.o -Iltreesitter/include -Itree-sitter/lib/include
gcc -O2 -fPIC -I/usr/include/lua5.1 -c ltreesitter/csrc/luautils.c -o ltreesitter/csrc/luautils.o -Iltreesitter/include -Itree-sitter/lib/include
gcc -O2 -fPIC -I/usr/include/lua5.1 -c ltreesitter/csrc/object.c -o ltreesitter/csrc/object.o -Iltreesitter/include -Itree-sitter/lib/include
gcc -O2 -fPIC -I/usr/include/lua5.1 -c ltreesitter/csrc/query.c -o ltreesitter/csrc/query.o -Iltreesitter/include -Itree-sitter/lib/include
gcc -O2 -fPIC -I/usr/include/lua5.1 -c ltreesitter/csrc/tree.c -o ltreesitter/csrc/tree.o -Iltreesitter/include -Itree-sitter/lib/include
gcc -O2 -fPIC -I/usr/include/lua5.1 -c ltreesitter/csrc/types.c -o ltreesitter/csrc/types.o -Iltreesitter/include -Itree-sitter/lib/include
gcc -O2 -fPIC -I/usr/include/lua5.1 -c ltreesitter/csrc/ltreesitter.c -o ltreesitter/csrc/ltreesitter.o -Iltreesitter/include -Itree-sitter/lib/include
gcc -O2 -fPIC -I/usr/include/lua5.1 -c ltreesitter/csrc/node.c -o ltreesitter/csrc/node.o -Iltreesitter/include -Itree-sitter/lib/include
gcc -O2 -fPIC -I/usr/include/lua5.1 -c ltreesitter/csrc/parser.c -o ltreesitter/csrc/parser.o -Iltreesitter/include -Itree-sitter/lib/include
gcc -O2 -fPIC -I/usr/include/lua5.1 -c ltreesitter/csrc/query_cursor.c -o ltreesitter/csrc/query_cursor.o -Iltreesitter/include -Itree-sitter/lib/include
gcc -O2 -fPIC -I/usr/include/lua5.1 -c ltreesitter/csrc/tree_cursor.c -o ltreesitter/csrc/tree_cursor.o -Iltreesitter/include -Itree-sitter/lib/include
gcc -O2 -fPIC -I/usr/include/lua5.1 -c tree-sitter/lib/src/lib.c -o tree-sitter/lib/src/lib.o -Iltreesitter/include -Itree-sitter/lib/include
In file included from tree-sitter/lib/src/././unicode.h:13,
                 from tree-sitter/lib/src/./lexer.c:5,
                 from tree-sitter/lib/src/lib.c:6:
tree-sitter/lib/src/././unicode/utf8.h:37:10: fatal error: unicode/umachine.h: No such file or directory
   37 | #include "unicode/umachine.h"
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.

Error: Failed installing dependency: https://luarocks.org/ltreesitter-ts-0.0.1-1.src.rock - Build error: Failed compiling object tree-sitter/lib/src/lib.o

Ubuntu Version 24.04.2 LTS

thomdin avatar Jun 06 '25 23:06 thomdin

The specific version of tree-sitter-cli is defined in the rockspec and should be installed during installation via LuaRocks automatically.

https://github.com/teal-language/teal-language-server/blob/52431adafda61fd45e1547ae45fe9a3d39c26bbe/teal-language-server-0.1.1-1.rockspec#L31-L32

A couple of options you can try:

  • There might be a path issue if binaries installed via LuaRocks don't show up on your path.
  • The teal-language-server unfortunately doesn't build with the latest tree-sitter-cli (one of our dependencies needs to be updated so we can use a newer version), so you could also try specifically installing 0.24.4 from cargo/npm
  • Use the setup script which will set the PATH locally and should get everything installed properly

Hopefully one of the things above works for you!

FourierTransformer avatar Jun 07 '25 14:06 FourierTransformer

I am trying to get the server installed under MSYS/MinGW and ran into the same issue. I finally got it installed, but I still get an error upon executing the server.

Here my workaround steps so far:

Workaround for installing ltreesitter-ts:

# the module is broken, the header exists, but the include directory is not passed correctly
luarocks install ltreesitter-ts CFLAGS="-O2 -fPIC -Itree-sitter/lib/src"

Installing the tree-sitter-cli package line fails under MinGW, but pacman has the binary anyways, so I had to fake the installation of tree-sitter-cli.

You may skip this step if the luarocks package `tree-sitter-cli` installs correctly under Ubuntu.
# replace the next line with the cargo package of tree-sitter if not already installed
# pacman -S $MINGW_PACKAGE_PREFIX-tree-sitter
mkdir /tmp/tree-sitter-cli
pushd /tmp/tree-sitter-cli
luarocks write_rockspec tree-sitter-cli 0.24.4 . --output tree-sitter-cli.rockspec.tpl
# write_rockspec does not create a valid rockspec, so we gsub the offending fields.
lua -e "io.write((io.read '*a':gsub('[%w_]*dependencies = %b{}', '')))" < ./tree-sitter-cli.rockspec.tpl > ./tree-sitter-cli-0.24.4-1.rockspec
# install the fake package then remove the temporary files
luarocks make
popd
rm -r /tmp/tree-sitter-cli

After applying these fixes (and one for luv) I could get the server installed, but running it yields errors. IDK if those errors are MSYS/MinGW specific, so if those fixes work for you, I'll create a seperate issue for MinGW.

$ teal-language-server
C:\msys64\ucrt64\bin\lua5.4.exe: Unable to load parser for teal
        Found C:\msys64\ucrt64\lib\lua\5.4\parser/teal.dll, but the version is too new, parser version: 15, maximum version: 14
        Found C:\msys64\ucrt64\bin\..\lib\lua\5.4\parser/teal.dll, but the version is too new, parser version: 15, maximum version: 14
        Tried C:\msys64\ucrt64\bin\..\lib\lua\5.4\loadall.dll: Error in LoadLibrary
        Tried .\parser/teal.dll: Error in LoadLibrary
        Tried C:\Users\Sebastian\.luarocks\lib\lua\5.4\parser/teal.dll: Error in LoadLibrary
stack traceback:
        [C]: in function 'ltreesitter.require'
        ...4\ucrt64\share\lua\5.4\teal_language_server\document.lua:12: in main chunk
        [C]: in function 'require'
        ...\share\lua\5.4\teal_language_server\document_manager.lua:7: in main chunk
        [C]: in function 'require'
        ...crt64\share\lua\5.4\teal_language_server\env_updater.lua:4: in main chunk
        [C]: in function 'require'
        ...sys64\ucrt64\share\lua\5.4\teal_language_server\main.lua:4: in main chunk
        [C]: in function 'require'
        ....4\teal-language-server\0.1.1-1\bin\teal-language-server:2: in main chunk
        [C]: in ?

sewbacca avatar Jul 06 '25 12:07 sewbacca

I think that error comes up if your version of tree-sitter-cli is newer than 0.24.7. Also what version of LuaRocks you're using?

Regardless of all that, if you just want to download binaries, we have them being built for 0.1.2 (currently in pre-release) on our Github Release page

FourierTransformer avatar Jul 06 '25 19:07 FourierTransformer

@FourierTransformer yes you are right, my tree-sitter installed from pacman is at version 0.25.x, so I did some digging why luarocks install tree-sitter-cli fails to install, since that's how I should get the correct version. See FourierTransformer/luarocks-build-tree-sitter-cli/issues/1 for details. After applying the specified patch, installing tree-sitter-cli via luarocks works now. tree-sitter --version delivers the correct version (< 0.24.7 as you specified), but the teal-language-server still throws the same error though:

$ tree-sitter --version
tree-sitter 0.24.4 (fc8c1863e2e5724a0c40bb6e6cfc8631bfe5908b)
$ teal-language-server
C:\msys64\ucrt64\bin\lua5.4.exe: Unable to load parser for teal
        Found C:\msys64\ucrt64\lib\lua\5.4\parser/teal.dll, but the version is too new, parser version: 15, maximum version: 14
        Found C:\msys64\ucrt64\bin\..\lib\lua\5.4\parser/teal.dll, but the version is too new, parser version: 15, maximum version: 14
        Tried C:\msys64\ucrt64\bin\..\lib\lua\5.4\loadall.dll: Error in LoadLibrary
        Tried .\parser/teal.dll: Error in LoadLibrary
        Tried C:\Users\Sebastian\.luarocks\lib\lua\5.4\parser/teal.dll: Error in LoadLibrary
stack traceback:
        [C]: in function 'ltreesitter.require'
        ...4\ucrt64\share\lua\5.4\teal_language_server\document.lua:12: in main chunk
        [C]: in function 'require'
        ...\share\lua\5.4\teal_language_server\document_manager.lua:7: in main chunk
        [C]: in function 'require'
        ...crt64\share\lua\5.4\teal_language_server\env_updater.lua:4: in main chunk
        [C]: in function 'require'
        ...sys64\ucrt64\share\lua\5.4\teal_language_server\main.lua:4: in main chunk
        [C]: in function 'require'
        ....4\teal-language-server\0.1.1-1\bin\teal-language-server:2: in main chunk
        [C]: in ?

When I ask luarocks, it says the dll comes from tree-sitter-teal and ltreesitter is also mentioned in the error above, so maybe the issue doesn't lie within the newer version of tree-sitter?

$ luarocks which parser.teal
C:\msys64\ucrt64\lib\lua\5.4\parser\teal.dll
(provided by tree-sitter-teal 0.0.33-1)
$ luarocks which ltreesitter
C:\msys64\ucrt64\lib\lua\5.4\ltreesitter.dll
(provided by ltreesitter-ts 0.0.1-1)

sewbacca avatar Jul 07 '25 09:07 sewbacca