The `debug` library is not available in Lua filters
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Rust
- Estrellas
- 302
- Forks
- 22
- Merge medio
- 5 h 8 min
- PR fusionados (30 d)
- 220
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de quarto-dev/q2
-
`q2 render` ignores `NO_COLOR` and prints colour codes and hyperlinks in its diagnosticsPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
quarto-dev/q2#1135 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
quarto-dev/q2#1133 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
quarto-dev/q2#1103 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
quarto-dev/q2#1095 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
quarto-dev/q2#1031 ·
Los mantenedores suelen responder en 1 día
Todos los issues de quarto-dev/q2
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
area:cli kind:docs prio:low
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
DecapodLabs/decapod#1626 · 1 comentario ·
Los mantenedores suelen responder en 1 día