`--output-dir` fails in a project that sets `project.output-dir`

Aperta Adatta ai principianti
#1,133 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
build-system

Direzione di ricerca

Inizia da crates/quarto-core/src/render_to_file.rs, dove --output-dir viene applicato all’output della pagina e viene configurato il resource resolver; confronta il percorso HTML con la gestione di docx e typst. Controlla in crates/quarto-core/src/resource_resolver.rs il controllo della radice consentita. Il lavoro è terminato quando il rendering con --output-dir out scrive la pagina e i file di supporto sotto out, lascia _site invariato e riporta out nel riepilogo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Bug description

To compare q2 with Quarto 1 on the dashboard from #1131, I wanted the q2 output in its own folder, away from the _site/ that Quarto 1 publishes.
The project sets output-dir: _site, and q2 render index.qmd --output-dir out stops on the first support file.
The relative and the absolute form of the path give the same error.

The page itself follows the option: when --output-dir is given, the project output-dir is skipped:

https://github.com/quarto-dev/q2/blob/8f17e950d26c68daae6e794c5fa513a96c0dae68/crates/quarto-core/src/render_to_file.rs#L763-L784

The writes, though, go through a resource resolver whose site_root is still the project output-dir, and that root is the only place the output sink accepts.
A comment in the same file describes this stock resolver and moves site_root for docx, typst and similar formats, but HTML keeps it:

https://github.com/quarto-dev/q2/blob/8f17e950d26c68daae6e794c5fa513a96c0dae68/crates/quarto-core/src/render_to_file.rs#L695-L716

https://github.com/quarto-dev/q2/blob/8f17e950d26c68daae6e794c5fa513a96c0dae68/crates/quarto-core/src/resource_resolver.rs#L318-L323

Steps to reproduce

_quarto.yml:

project:
  type: default
  output-dir: _site

index.qmd:

---
title: Hello
---

Hello.
q2 render index.qmd --output-dir out
quarto render index.qmd --output-dir out
Actual behavior

q2 writes nothing:

Rendering project: <dir> (type: default)
error: <dir>/index.qmd: output destination <dir>/out/index_files/quarto/quarto-theme-d9a3a2debf57bcb1.css is not under any allowed root (<dir>/_site)
Rendered 0 of 1 files to <dir>/_site — 1 error

The summary line names _site, not out.
Quarto 1 writes out/index.html and out/index_files/, and leaves _site/ alone.

Expected behavior

out/ gets the page and its support files, as with Quarto 1, and the summary names out.
Building the resolver with site_root set to the --output-dir value whenever the option is given would cover it.

Your environment
  • q2: q2 (quarto 2) 0.43.0-nightly.20261109 (nightly built from 8f17e95), and q2 v0.42.0.
  • Quarto 1 for comparison: development build of quarto-dev/quarto-cli@fa74261.
  • OS: macOS 27.2 (arm64).
  • Terminal, no IDE.
Lingua principale
Rust
Stelle
302
Fork
22
Merge medio
5h 6m
PR unite (30g)
207

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di quarto-dev/q2

Tutte le issue di quarto-dev/q2

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.