LuaLS / vscode-lua

Release lua-language-server for VSCode
https://github.com/LuaLS/lua-language-server
MIT License
181 stars 52 forks source link

Many "Couldn't find message for key" errors when running VS Code #72

Closed lkrms closed 1 year ago

lkrms commented 1 year ago

Since a recent update to this extension (I'm not sure which one, sorry), I've started seeing errors like the below whenever I run code from a terminal (e.g. when provisioning vscode extensions from shell scripts).

Although it doesn't break anything, it does bloat the output of scripts and obfuscates important messages.

The values listed don't appear in the extension's package.nls.json file, so presumably resolving the issue should be as simple as adding them?

Thanks for all of your work on a great extension!

[lua]: Couldn't find message for key config.diagnostics.circle-doc-class.
[lua]: Couldn't find message for key config.diagnostics.invisible.
[lua]: Couldn't find message for key config.diagnostics.circle-doc-class.
[lua]: Couldn't find message for key config.diagnostics.invisible.
[lua]: Couldn't find message for key config.runtime.builtin.basic.
[lua]: Couldn't find message for key config.runtime.builtin.bit.
[lua]: Couldn't find message for key config.runtime.builtin.bit32.
[lua]: Couldn't find message for key config.runtime.builtin.builtin.
[lua]: Couldn't find message for key config.runtime.builtin.coroutine.
[lua]: Couldn't find message for key config.runtime.builtin.debug.
[lua]: Couldn't find message for key config.runtime.builtin.ffi.
[lua]: Couldn't find message for key config.runtime.builtin.io.
[lua]: Couldn't find message for key config.runtime.builtin.jit.
[lua]: Couldn't find message for key config.runtime.builtin.math.
[lua]: Couldn't find message for key config.runtime.builtin.os.
[lua]: Couldn't find message for key config.runtime.builtin.package.
[lua]: Couldn't find message for key config.runtime.builtin.string.
[lua]: Couldn't find message for key config.runtime.builtin.string.buffer.
[lua]: Couldn't find message for key config.runtime.builtin.table.
[lua]: Couldn't find message for key config.runtime.builtin.table.clear.
[lua]: Couldn't find message for key config.runtime.builtin.table.new.
[lua]: Couldn't find message for key config.runtime.builtin.utf8.
[lua]: Couldn't find message for key config.runtime.fileEncoding.utf8.
[lua]: Couldn't find message for key config.runtime.fileEncoding.ansi.
[lua]: Couldn't find message for key config.runtime.fileEncoding.utf16le.
[lua]: Couldn't find message for key config.runtime.fileEncoding.utf16be.
[lua]: Couldn't find message for key config.runtime.version.Lua 5.1.
[lua]: Couldn't find message for key config.runtime.version.Lua 5.2.
[lua]: Couldn't find message for key config.runtime.version.Lua 5.3.
[lua]: Couldn't find message for key config.runtime.version.Lua 5.4.
[lua]: Couldn't find message for key config.runtime.version.LuaJIT.
[lua]: Couldn't find message for key config.typeFormat.config.
[lua]: Couldn't find message for key config.typeFormat.config.auto_complete_end.
[lua]: Couldn't find message for key config.typeFormat.config.auto_complete_table_sep.
[lua]: Couldn't find message for key config.typeFormat.config.format_line.
[lua]: Couldn't find message for key config.diagnostics.circle-doc-class.
[lua]: Couldn't find message for key config.diagnostics.invisible.
[lua]: Couldn't find message for key config.diagnostics.circle-doc-class.
[lua]: Couldn't find message for key config.diagnostics.invisible.
[lua]: Couldn't find message for key config.runtime.builtin.basic.
[lua]: Couldn't find message for key config.runtime.builtin.bit.
[lua]: Couldn't find message for key config.runtime.builtin.bit32.
[lua]: Couldn't find message for key config.runtime.builtin.builtin.
[lua]: Couldn't find message for key config.runtime.builtin.coroutine.
[lua]: Couldn't find message for key config.runtime.builtin.debug.
[lua]: Couldn't find message for key config.runtime.builtin.ffi.
[lua]: Couldn't find message for key config.runtime.builtin.io.
[lua]: Couldn't find message for key config.runtime.builtin.jit.
[lua]: Couldn't find message for key config.runtime.builtin.math.
[lua]: Couldn't find message for key config.runtime.builtin.os.
[lua]: Couldn't find message for key config.runtime.builtin.package.
[lua]: Couldn't find message for key config.runtime.builtin.string.
[lua]: Couldn't find message for key config.runtime.builtin.string.buffer.
[lua]: Couldn't find message for key config.runtime.builtin.table.
[lua]: Couldn't find message for key config.runtime.builtin.table.clear.
[lua]: Couldn't find message for key config.runtime.builtin.table.new.
[lua]: Couldn't find message for key config.runtime.builtin.utf8.
[lua]: Couldn't find message for key config.runtime.fileEncoding.utf8.
[lua]: Couldn't find message for key config.runtime.fileEncoding.ansi.
[lua]: Couldn't find message for key config.runtime.fileEncoding.utf16le.
[lua]: Couldn't find message for key config.runtime.fileEncoding.utf16be.
[lua]: Couldn't find message for key config.runtime.version.Lua 5.1.
[lua]: Couldn't find message for key config.runtime.version.Lua 5.2.
[lua]: Couldn't find message for key config.runtime.version.Lua 5.3.
[lua]: Couldn't find message for key config.runtime.version.Lua 5.4.
[lua]: Couldn't find message for key config.runtime.version.LuaJIT.
[lua]: Couldn't find message for key config.typeFormat.config.
[lua]: Couldn't find message for key config.typeFormat.config.auto_complete_end.
[lua]: Couldn't find message for key config.typeFormat.config.auto_complete_table_sep.
[lua]: Couldn't find message for key config.typeFormat.config.format_line.
sumneko commented 1 year ago

Where can I find these messages?

carsakiller commented 1 year ago

I noticed these messages in the developer tools console that are opened from the command palette. I couldn't find a console.warn responsible if I remember correctly, so I think it is maybe part of the LSP protocol.

lkrms commented 1 year ago

Just run a command like code --list-extensions from a terminal session. The errors appear before the extension list for me.

They do also show up in the developer tools console.

lkrms commented 1 year ago

I noticed these messages in the developer tools console that are opened from the command palette. I couldn't find a console.warn responsible if I remember correctly, so I think it is maybe part of the LSP protocol.

The message appears to be logged by a localisation framework (I'm guessing it's this one?), so that's where you're most likely to find the relevant console.warn.

Incidentally, I'm running VSCode in the en_AU.utf8 locale, which may be relevant if you happen to be using a non-English locale, perhaps with a more complete translation file?

lkrms commented 1 year ago

Given how often my terminal fills up with these errors, I cloned the repo to investigate further.

As best I can tell, you're generating package.json, package.nls.json, etc. from a Lua build tool + separate schema, so I couldn't jump in and prepare a PR, but I can confirm that out of the 28 missing keys:

Rather than generating a translation file with empty values, or adding redundant descriptions to enum values that are self-documenting, suppressing "description" fields when generating package.json if there is no known description should solve this issue without any loss of functionality and (theoretically, at least) minimal loss of time.

notpeter commented 1 year ago

Note, this issue is also tracked here: https://github.com/LuaLS/lua-language-server/issues/1845

This was almost fixed in e6b153552866a565a91d94de465873c6cc754ad7 as suggested in this comment, but sadly empty strings "" don't solve the issue. If you provide any non-empty string (e.g. "TODO: Add documentation") it fixes all the errors. So close.

In the meantime, you can hotfix your local extension to suppress the error:

sed -i.bak -e 's/""/"TODO: Add documentation"/' ~/.vscode/extensions/sumneko.lua*/*.nls*.json 

And if you want to revert back to the release version just run:

code --uninstall-extension sumneko.lua
rm -rf ~/.vscode/extensions/sumneko.lua*
code --install-extension sumneko.lua

@lkrms: I too couldn't figure out the build system to prepare a PR (and I tried).

@sumneko: Any chance we could get some documentation on how to get a development environment setup for vscode-lua? I tried on this branch but did not get a functioning Lua environment setup. Would love some notes about your development workflow.