Skip to content

Fix embed notebook preview missing from _site on re-render - #15006

Open
cderv wants to merge 6 commits into
mainfrom
fix/issue-10756
Open

cderv wants to merge 6 commits into
mainfrom
fix/issue-10756

Conversation

@cderv

@cderv cderv commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Description

When a page embeds a .qmd notebook with embed and the project is rendered a second time, the embed's preview page and its figure files are missing from _site, and the link to the source notebook returns 404.

After the first render, the embedded notebook is revived from its scratch cache in .quarto/embed/ instead of being rendered again. The preview was then rendered beside the cached copy, inside .quarto/embed/, while the output was recorded at its project path. The output relocation skips supporting paths whose source does not exist, so nothing was copied to _site. The cache-and-revive path dates from 47269ca (2023).

Fix

A notebook revived from the cache is now copied to <stem>.embed.ipynb beside the source, rendered from there, and the copy is removed in a finally block. A fresh render writes the same file, so the preview and figure files land where they would on a first render and the existing relocation and cleanup apply unchanged. An existing <stem>.embed.ipynb is overwritten, as a fresh render also does.

A notebook revived from the cache is no longer cached again, because caching it nested a second copy at .quarto/embed/.quarto/embed/.

The tests/docs/site/.gitignore change ignores **/*.quarto_ipynb files.

The new test runs from the project directory. A render started from another directory loses the preview independently of this change (#15004), so the test sets cwd to the project directory.

Test Plan

  • smoke/embed/render-embed-website-rerender.test.ts passes with the fix
  • With the fix reverted, the test fails because _site/source.embed-preview.html does not exist
  • With only the re-caching change reverted, the test fails on the nested .quarto/embed/.quarto path
  • A manual Python website with freeze: auto, rendered three times from the project directory, keeps the preview, the source.embed_files figure, and source.qmd in _site on every render, with no nested cache directory and no leftover source.embed.ipynb
  • smoke/embed/render-embed (3/3), smoke/site/render-site (1/1), and smoke/manuscript/render-manuscript (5/5) pass

Fixes #10756

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR
AI-assisted PR
  • AI tool used: Claude Code
  • Codebase grounding: local clone
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.

cderv added 3 commits October 7, 2026 17:26
After the first render, the embed notebook of a qmd source is revived from the `.quarto/embed` scratch cache, and its preview was rendered next to the cached copy. The preview and its figure files therefore never reached `_site`, and the "Source" link of the embed 404'd.

Rendering the preview from a staged copy beside the source restores the layout of a fresh render, so the existing relocation and cleanup apply unchanged. A notebook revived from the cache is also no longer cached again, which nested `.quarto/embed/.quarto/embed/`.

The test runs from the project directory because a render started from another directory loses the preview independently of this change (#15004).

Fixes #10756
@posit-snyk-bot

posit-snyk-bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

cderv added 3 commits October 8, 2026 15:59
The test renders from the project directory (#15004), so the knitr subprocess starts outside tests/ and never sources tests/.Rprofile. On CI rmarkdown only lives in the tests/renv library, so the render failed with 'there is no package called rmarkdown'. Write a .Rprofile in setup that re-activates renv against tests/, as other cwd-changing R tests do.
Two tests now write the same .Rprofile to re-activate the tests/ renv project. A helper in tests/utils.ts derives the tests/ path from its own location instead of counting dirname() levels per test file.
The path-scoped rule only matched one unit test, so the embed smoke test and future cwd-changing R tests never loaded it. Scope it to both tests, name the helper, and cross-link from the working-directory section of the testing patterns.
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.

A website using embed and freeze is missing files on second render

2 participants