Skip to content

Conversation

@Freed-Wu
Copy link
Contributor

@Freed-Wu Freed-Wu commented Aug 17, 2025

Test file:

test.lua:

---@param x integer
function f(x)
    x = "a"
end
---
repos:
  - repo: https://github.com/LuaLS/lua-language-server
    rev: 3.16.0
    hooks:
      - id: lua-language-server-check
Screenshot_20250822_164637

PS: luarocks.org doesn't support host binary lua module, which means users have to build bee.lua from source code, which will cost long time and easy to fail due to poor network and miss dependencies of libunwind and libbfd. I try to provide a luarocks server and it can be used by:

~/.config/luarocks/config-5.1.lua:

rocks_servers = {
    "https://rimeinn.github.io/ime.nvim",
    "https://luarocks.org",
}

The binary module is built in ubuntu, which will not work out of box in other OSes due to some problem like unmatched libbfd version:

$ ldd /home/wzy/.cache/pre-commit/repopwkmc8b0/lua_env-default/lib/luarocks/rocks-5.1/bee.lua/1.7-3/bin/bootstrap
ldd: warning: you do not have execution permission for `/home/wzy/.cache/pre-commit/repopwkmc8b0/lua_env-default/lib/luarocks/rocks-5.1/bee.lua/1.7-3/bin/bootstrap'
        linux-vdso.so.1 (0x00007f8f0bdf8000)
        libunwind.so.8 => /nix/store/l1a7d2hc236a66bzdbcyg91w4snb1ggl-libunwind-1.8.3/lib/libunwind.so.8 (0x00007f8f0bd3a000)
        libbfd-2.42-system.so => not found
        libm.so.6 => /nix/store/rcp9sdrrq8sfxkm5zdykglx7hd2gzbfy-glibc-2.40-66/lib/libm.so.6 (0x00007f8f0bc52000)
        libstdc++.so.6 => not found
        libc.so.6 => /nix/store/rcp9sdrrq8sfxkm5zdykglx7hd2gzbfy-glibc-2.40-66/lib/libc.so.6 (0x00007f8f0ba00000)
        liblzma.so.5 => /nix/store/y725ml8s15w81wmjfq73px2qvyrg5g97-xz-5.8.1/lib/liblzma.so.5 (0x00007f8f0bc1e000)
        libpthread.so.0 => /nix/store/rcp9sdrrq8sfxkm5zdykglx7hd2gzbfy-glibc-2.40-66/lib/libpthread.so.0 (0x00007f8f0bc19000)
        /lib64/ld-linux-x86-64.so.2 => /nix/store/rcp9sdrrq8sfxkm5zdykglx7hd2gzbfy-glibc-2.40-66/lib64/ld-linux-x86-64.so.2 (0x00007f8f0bdfa000)
$ ls /nix/store/n5md3cf7bpik1kbii2i1y3i7p50g1fwy-binutils-2.44-lib/lib/libbfd*so
/nix/store/n5md3cf7bpik1kbii2i1y3i7p50g1fwy-binutils-2.44-lib/lib/libbfd-2.44.so  /nix/store/n5md3cf7bpik1kbii2i1y3i7p50g1fwy-binutils-2.44-lib/lib/libbfd.so

So you have to copy a correct bootstrap:

cp /nix/store/w42pww1mwxw3fwdrngjvsm5p2d8j7wb2-lua-language-server-3.15.0/share/lua-language-server/bin/lua-language-server /home/wzy/.cache/pre-commit/repopwkmc8b0/lua_env-default/lib/luarocks/rocks-5.1/bee.lua/1.7-3/bin/bootstrap

Another problem is luarocks/luarocks#1548 (comment)

/home/wzy/.cache/pre-commit/repopwkmc8b0/lua_env-default/bin/lua-language-server is a shell wrapper to call /home/wzy/.cache/pre-commit/repopwkmc8b0/lua_env-default/lib/luarocks/rocks-5.1/lua-language-server/scm-1/bin/lua-language-server , which will call bee, however, the dir of /home/wzy/.cache/pre-commit/repopwkmc8b0/lua_env-default/bin/bee is not in $PATH. You can:

  • add PATH="/home/wzy/.cache/pre-commit/repopwkmc8b0/lua_env-default/bin${PATH+:}$PATH" to /home/wzy/.cache/pre-commit/repopwkmc8b0/lua_env-default/bin/lua-language-server
  • or copy a lua-language-server to $PATH's bee.

@Freed-Wu Freed-Wu marked this pull request as draft August 17, 2025 22:37
@Freed-Wu Freed-Wu force-pushed the pre-commit branch 2 times, most recently from a4ebc5c to 70aaa4d Compare August 20, 2025 15:42
@Freed-Wu Freed-Wu marked this pull request as ready for review August 20, 2025 15:51
@Freed-Wu Freed-Wu marked this pull request as draft August 20, 2025 17:28
@Freed-Wu Freed-Wu marked this pull request as ready for review August 22, 2025 08:47
@sumneko sumneko merged commit fe72ef9 into LuaLS:master Dec 2, 2025
9 of 10 checks passed
@sumneko
Copy link
Collaborator

sumneko commented Dec 2, 2025

Thank you!

@Freed-Wu Freed-Wu deleted the pre-commit branch December 4, 2025 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants