LuaLS / LuaLS/lua-language-server

Error when exporting Lua language server documentation

オープン
#3,170 コメント 3 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Lua
スター
4.4k
フォーク
442
PR マージ指標
30日以内にマージされた PR はありません

説明

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Other

Expected Behaviour

documentation export

Actual Behaviour

I encountered an error when trying to export documentation using the Lua language server (sumneko.lua-3.14.0):
[error]: script\cli\doc\export.lua:61: bad argument #1 to 'canonical' (bee::path expected, got nil)

Reproduction steps
  1. Install sumneko.lua-3.14.0 extension in VS Code
  2. Create a simple Lua project with documentation comments
  3. Try to export documentation (through command palette)
Additional Notes

This appears to be a regression or oversight in the extension where it attempts to use a variable before it's defined. The fix is straightforward and might help other users encountering the same issue.

Solution

I fixed this by modifying script\cli\doc\export.lua to define the DOC variable with a simpler fallback approach that doesn't rely on non-existent functions:

-- Define DOC variable to avoid nil error
local DOC = DOC or (ws.rootUri and fs.path(furi.decode(ws.rootUri)) or fs.current_path())

This simple fix ensures that DOC is always defined with a valid path value before it's used in the getLocalPath function, allowing the documentation export functionality to work properly.

Log File

[00:02:10.453][error][#0]: script\cli\doc\export.lua:61: bad argument #1 to 'canonical' (bee::path expected, got nil)
stack traceback:
[C]: in function 'bee.filesystem.canonical'
script\cli\doc\export.lua:61: in field 'getLocalPath'
script\cli\doc\export.lua:170: in field '?'
script\cli\doc\export.lua:118: in field 'documentObject'
script\cli\doc\export.lua:261: in field 'variable'
script\cli\doc\export.lua:235: in field '?'
script\cli\doc\export.lua:118: in field 'documentObject'
script\cli\doc\export.lua:287: in field 'makeDocs'
script\cli\doc\init.lua:162: in function 'cli.doc.makeDoc'
script\core\command\exportDocument.lua:10: in function 'core.command.exportDocument'
script\provider\provider.lua:1009: in function <script\provider\provider.lua:987>
[C]: in function 'xpcall'
script\proto\proto.lua:202: in function <script\proto\proto.lua:177>

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

script/cli/doc/export.lua、特に 61 行目の getLocalPath から始め、Lua プロジェクトで VS Code のコマンドパレットからドキュメントをエクスポートして失敗を再現します。提案されたパスのフォールバックを確認し、ドキュメントのエクスポートが nil-path の canonical エラーなしに完了することを検証してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
lua, vscode
領域
documentation
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。