fix(manuscript): keep knitr figures on Windows on first freeze render#14633
Merged
Conversation
On a manuscript first render with freeze, renderCleanup compared the engine-reported supporting dir to the normalized filesDir with a raw string equality. The knitr engine reports paths with forward slashes on Windows while filesDir uses the platform separator, so the comparison failed there and the parent index_files dir was removed wholesale instead of being narrowed to the figure dir. Subsequent format completions then found no index_files and copied nothing into _manuscript. Only knitr is affected; the Jupyter engine builds the path with the platform separator, which already matches. Compare paths separator-agnostically via a new pathsEqual helper, and adopt it at the two existing preview call sites that hand-rolled the same normalize-both-sides comparison.
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. |
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.
When rendering a manuscript project with
freeze: autoand the knitr engine on Windows, dynamically generated figures are missing from the rendered manuscript on the first render (or after clearing freeze). Subsequent renders or--cache-refreshsucceeds.Root Cause
renderCleanupcompares the engine-reported supporting directory to the computedfilesDirto decide whether to narrow cleanup to the figure subdirectory or remove the full supporting dir. The knitr engine reports paths with forward slashes on Windows whilefilesDiris normalized to the platform separator (backslash), so the raw===comparison fails there. The parentindex_filesdirectory is removed wholesale instead of being narrowed tofigure-<format>. Subsequent format completions find noindex_filesand copy nothing into_manuscript.Only knitr is affected; the Jupyter engine already uses the platform separator.
Fix
Added a
pathsEqualhelper tosrc/core/path.tsthat normalizes both sides before comparing. Used at therenderCleanupcomparison and at two preview call sites that were hand-rolling the same normalize-both-sides pattern.Fixes #14613