Skip to content

Fix .quarto_ipynb files not cleaned up after render#14366

Draft
cderv wants to merge 4 commits intomainfrom
fix/issue-14359
Draft

Fix .quarto_ipynb files not cleaned up after render#14366
cderv wants to merge 4 commits intomainfrom
fix/issue-14359

Conversation

@cderv
Copy link
Copy Markdown
Collaborator

@cderv cderv commented Apr 15, 2026

When rendering a .qmd file with Jupyter execution, the intermediate .quarto_ipynb file is never deleted. Each subsequent preview creates numbered variants (_1, _2, etc.) that accumulate on disk.

Root Cause

PR #12793 added keep-ipynb: true support by integrating cleanupNotebook() with fileInformationCache. As a side effect, it dropped the immediate file deletion for the default keep-ipynb: false case. The function only flips a transient flag in the cache when keep-ipynb: true is set, but does nothing otherwise — the file just stays on disk.

Fix

Add an else if (data.transient) branch in cleanupNotebook() that calls safeRemoveSync(target.input) when keep-ipynb is false, restoring the original deletion behavior while preserving the cache integration for keep-ipynb: true.

This is safe because execute() already has a guard (lines 441-447) that recreates the notebook if it's missing, and safeRemoveSync tolerates missing files.

Also adds fileNotExists verification to the smoke-all test framework and a test that verifies the .quarto_ipynb file is cleaned up after render.

Fixes #14359

cderv added 4 commits April 16, 2026 11:52
- Add `fileNotExists` to verify.ts, mirroring `fileExists` but calling
  `verifyNoPath` instead of `verifyPath`
- Wire `fileNotExists` into smoke-all.test.ts verifyMap handling block
  alongside the existing `fileExists` block
- Add smoke-all test 14359.qmd that verifies the .quarto_ipynb intermediate
  file is cleaned up after render when keep-ipynb defaults to false
When keep-ipynb is false (the default), cleanupNotebook() now calls
safeRemoveSync() to delete the intermediate .quarto_ipynb file immediately
after execution, restoring the original behavior from 2021 that was
inadvertently dropped when keep-ipynb support was added in PR #12793.
@cderv cderv force-pushed the fix/issue-14359 branch from d47908c to 465bd81 Compare April 16, 2026 09:52
@cderv cderv marked this pull request as draft April 16, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.quarto_ipynb files not cleaned up when preview is killed ungracefully

1 participant