The `debug` library is not available in Lua filters
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start in crates/pampa/src/lua/filter.rs: inspect the filter environment setup around Lua::new() (lines 177–192) and the chunk name setup (lines 383–386). Reproduce with the supplied filter.lua and index.qmd using q2 render index.qmd --to html; compare with Quarto 1 if useful. Done when the filter can use debug.getinfo to obtain its running chunk path without dropping a path character.
索引モデルが issue の本文から書いたものです。
説明
Bug description
The global debug is nil in a Lua filter, so a call to debug.getinfo stops the render.
Extensions use this call to find the directory of the module that is running.
For example, a load_sibling helper that several of my extensions vendor reads debug.getinfo(1, "S").source, then loads a neighbouring file with require.
Three of the 40 extensions (all mine) I tested call debug.getinfo in their Lua files.
Quarto 1 runs Lua through Pandoc, which exposes the full debug library.
This is the Quarto 1 way of doing it, and a better way might be worth exploring in q2.
Both engines already cover the common cases without debug, which I checked on q2 and on Quarto 1.12.0:
- A relative
require("./b")in a nested module loads the neighbouringb.lua. PANDOC_SCRIPT_FILEgives the path of the filter script.quarto.utils.resolve_pathresolves a path against the filter directory.
None of them gives a module its own path, and extensions that call debug.getinfo break today.
The filter environment uses Lua::new(), which skips debug as unsafe, although the comment says native builds load everything:
The chunk name of the filter script is set without a leading @, so once debug is loaded, source:sub(2) would still drop the first character of the path:
Steps to reproduce
filter.lua:
function Pandoc()
return pandoc.Pandoc(pandoc.Para(pandoc.Str(debug.getinfo(1, "S").source)))
end
index.qmd:
---
filters:
- filter.lua
---
x
Render it with q2 and with Quarto 1:
q2 render index.qmd --to html
quarto render index.qmd --to html
Actual behavior
Rendering single file: /private/tmp/q2-debug.Eqp8/index.qmd
error: while rendering /private/tmp/q2-debug.Eqp8/index.qmd
Error: Lua filter error: runtime error: [string "/private/tmp/q2-debug.Eqp8/filter.lua"]:2: attempt to index a nil value (global 'debug')
stack traceback:
[string "/private/tmp/q2-debug.Eqp8/filter.lua"]:2: in function 'Pandoc'
1 error
Expected behavior
debug.getinfo(1, "S").source returns the path of the running chunk with a leading @, as in standard Lua.
Quarto 1 writes it into the page:
<p>@filter.lua</p>
Your environment
- q2:
Q2 (quarto 2) 0.40.0-nightly.20261101(nightly built from a2a1cb9). - Quarto 1 for comparison: 1.12.0 (pre-release).
- OS: macOS 27.2 (arm64).
- Terminal, no IDE.
- 主要言語
- Rust
- スター
- 302
- フォーク
- 22
- 平均マージ
- 5時間 8分
- マージ済み PR(30日)
- 220
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
quarto-dev/q2 のほかの issue
-
`q2 render` ignores `NO_COLOR` and prints colour codes and hyperlinks in its diagnostics対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
quarto-dev/q2#1135 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
quarto-dev/q2#1133 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
quarto-dev/q2#1103 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
quarto-dev/q2#1095 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
quarto-dev/q2#1031 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
area:cli kind:docs prio:low
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
DecapodLabs/decapod#1626 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信