CGPT Quarto Render Windows
Use this skill for Windows .qmd render failures caused by spawned-shell environment drift. Keep it separate from source-content debugging: if the failure is shell inheritance, stale output, or R discovery, fix the render lane before editing manuscript prose.
Common Diagnosis
Treat these as environment problems until evidence says otherwise:
cmdnot found or Quarto cannot spawncmd.exe.quartoworks in RStudio but not from Codex or a scheduled script.$env:PATHEXTis.CPLonly or lacks.EXE;.CMD.- R path is pinned to an older version directory.
- Render exits 0 but the output file timestamp did not advance.
- Quarto logs mention
rBinaryPath,checkRBinary, orFailed to spawn 'CMD'.
Immediate Diagnostics
Run in the same spawned PowerShell context that will render:
Get-Command cmd -ErrorAction SilentlyContinue
$env:PATHEXT
Get-Command quarto -ErrorAction SilentlyContinue
$env:PATH.Substring(0, [Math]::Min(200, $env:PATH.Length))
If any command resolution is missing, patch the render script with the reusable preamble before changing manuscript content.
Attempt Ceiling
Do not loop indefinitely on render failures.
- Count a failed render, non-advancing output timestamp, or silent no-op as a strike.
- Stop after three strikes and hand the user a concise render-bailout report with the attempted commands, output paths, log path, and recommended next lane.
- If the failure is deterministic
rBinaryPath,checkRBinary, orFailed to spawn 'CMD'from a sandboxed/Cowork child process, treat strike 1 as strike 3. A fourth shell variant will not fix that layer.
Reusable Preamble
Copy assets/_render_preamble.ps1 into the project, usually next to render scripts or under a shared scripts/ folder. Dot-source it at the top of every Windows render script:
. "$PSScriptRoot\_render_preamble.ps1"
The preamble restores PATHEXT, critical Windows paths, Quarto path, latest installed R path, and [Environment]::CurrentDirectory.
Render Script Pattern
- Dot-source the preamble.
- Capture the pre-render output
LastWriteTime. - Run
quarto renderand tee stdout/stderr to a log. - Fail if
$LASTEXITCODEis nonzero. - Fail if the expected output file does not exist or its timestamp did not advance.
- Run
cgpt-render-checkon the output before delivery.
RStudio Handoff
Use an RStudio Terminal handoff when the render must execute R/Python chunks and the current spawned context cannot provide a reliable Windows child process environment.
Triggers:
.qmdhas executable chunks that are not frozen and noteval: false.- The project is under a Windows OneDrive path and the current render lane is Cowork/sandboxed or otherwise failing at R discovery.
- Logs contain
rBinaryPath,checkRBinary,quarto.js, orFailed to spawn 'CMD'. - Output mtime remains older than the source after an apparent success.
Handoff protocol:
- Stop trying new shell wrappers.
- Write a project-local
scripts/render-[stem].ps1only if useful for repeatability. - Give the user a concrete RStudio Terminal command using forward slashes in paths.
- After the user renders, verify the output
LastWriteTimeis newer than the source and runcgpt-render-check.
Template:
cd "C:/Users/sundar/OneDrive - UW/Documents/GitHub/RESEARCH/[PROJECT]/[MANUSCRIPT_FOLDER]"
quarto render [FILE].qmd --to docx
Replace every bracketed placeholder before handing it to the user. Do not use angle-bracket placeholders in project-facing handoff text.
Rules
- Do not treat exit code 0 as sufficient proof of a fresh render.
- Do not hardcode one R version when multiple versions may exist.
- Do not patch prose or citations while diagnosing shell environment failures.
- Keep render logs with the generated output when the project is delivery-grade.
- Do not declare a render clean until output mtime, file size, and format-specific checks have been verified.