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

rootUri is incorrect in VS Code extension

Open JayRPlayz opened this issue 7 months ago • 1 comments

Whenever i open a specific workspace, that i have currently saved, it lags my pc for a solid few minutes, making it completely usable during that time. Disableling the lua extension (by summeko) seems to fix the issue. it also sais that its scanning "" and

Image

that its trying to load several thousand files. how do i fix this?

JayRPlayz avatar Jun 15 '25 06:06 JayRPlayz

not enough information 😕

suggest you to read: https://luals.github.io/wiki/faq/#how-can-i-improve-startup-speeds

TL;DR: Only include necessary libraries and ignore as many files/directories as you can.

The most effective (and obvious) way to improve startup times is to load fewer files. The startup time of the server is proportional to the total size of all Lua files in your workspace. Try excluding unnecessary directories and files using workspace.ignoreDir.

LuaLS will always scan all files in your workspace, because it has to preload all possible lua files to make type inferencing works. To prevent LuaLS scanning undesired folders, you can create a .luarc.json config file and play around with the workspace.ignoreDir setting mentioned above:

{
    "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",

    "workspace.ignoreDir": [
        "i_dont_want_this_folder",
        "i_want_this_folder/but_not_this_sub_folder"
    ]
}

tomlau10 avatar Jun 17 '25 01:06 tomlau10

Not working for me, and based on message in VSCode, language server tries to scan every single file on system starting from '' (even that I am on Windows) More than 100000 files have been scanned. The current scanned directory is '\'. Why it is even trying to scan whole system, instead of only workspace? How to fix this?

I only use workspace.json, and only have one entry:

"Lua.workspace.ignoreDir": [
	".vscode"
]

In server log rootUri and rootPath are targeting my workspace folder (which I assume is correct behavior):

  rootPath = "c:\\_Datas\\Git\\_TEMP_\\mc-cc-scada",
  rootUri = "file:///c%3A/_Datas/Git/_TEMP_/mc-cc-scada",

Luminisc avatar Jul 19 '25 11:07 Luminisc

I only use workspace.json, and only have one entry:

I have never heard of workspace.json 😳 Do you mean .vscode/settings.json or a multi-root workspace config file?

test on a dummy workspace ?

Does it work on other workspace / a newly created workspace? Say you create a dummy & empty workspace on C:\test\, with only a test.lua there. Does it work there?

other things to look into 🤔

  • do you have any other Lua.* config in you global user settings json?
  • does your workspace contains symlinks that links to other folders/directories ? I have replied to some similar scan too many files issues before, and finally the reason is that they contain symlinks in the workspace 😇 https://github.com/LuaLS/lua-language-server/issues/2849#issuecomment-2351274661

@Luminisc

tomlau10 avatar Jul 20 '25 10:07 tomlau10

FYI: if I use dummy project with just few files, language server works as intended and scanning only workspace files. But... Looks like I found the reason of my problem. I am using CraftOS extension for VSCode (https://github.com/MCJack123/vscode-craftos-pc), that allows to get access to computers in minecraft. Most important thing here - this extension allow to get direct access to filesystem of this computers and add their filesystems to current workspace. So here is the problem - when language server tries to scan files, it gets rootUrl as '\' from this new attached workspace, and uses this '\'-url to scan files not only on attached workspace, but on my host system as well, which leads to loading all files on my computer. I think this problem should be raised on extension's github first, but I feel like there is might be a problem on language server side as well...

Luminisc avatar Jul 28 '25 10:07 Luminisc

Looks like I found the reason of my problem. I am using CraftOS extension for VSCode

Okay, so your problem is actually related to CraftOS and I believe it is tracked in another issue here: https://github.com/LuaLS/lua-language-server/issues/2317 🤔

tomlau10 avatar Jul 29 '25 01:07 tomlau10