Repository navigation
Conversation
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
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a page embeds a
.qmdnotebook withembedand 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.ipynbbeside the source, rendered from there, and the copy is removed in afinallyblock. 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.ipynbis 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/.gitignorechange ignores**/*.quarto_ipynbfiles.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
cwdto the project directory.Test Plan
smoke/embed/render-embed-website-rerender.test.tspasses with the fix_site/source.embed-preview.htmldoes not exist.quarto/embed/.quartopathfreeze: auto, rendered three times from the project directory, keeps the preview, thesource.embed_filesfigure, andsource.qmdin_siteon every render, with no nested cache directory and no leftoversource.embed.ipynbsmoke/embed/render-embed(3/3),smoke/site/render-site(1/1), andsmoke/manuscript/render-manuscript(5/5) passFixes #10756
Checklist
I have (if applicable):
AI-assisted PR
Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.