-
Notifications
You must be signed in to change notification settings - Fork 401
Manage projectcontext objects correctly on preview #13804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ 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 last failing test is interesting. If I'm reading the messages correctly, we previously had:
Now that things are properly connected, the test fails. But it seems that this test shouldn't really even be there? |
f89c530 to
6db3515
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test failure in render-output-dir.test.ts (and the other playwright docs/playwright/embed-resources/issue-11860/main.qmd) is caused by a logic ordering issue at:
quarto-cli/src/command/render/render-shared.ts
Lines 51 to 63 in e48007d
| let context = pContext || (await projectContext(path, nbContext, options)) || | |
| (await singleFileProjectContext(path, nbContext, options)); | |
| // Create a synthetic project when --output-dir is used without a project file | |
| // This creates a temporary .quarto directory to manage the render, which must | |
| // be fully cleaned up afterward to avoid leaving debris (see #9745) | |
| if (!context && options.flags?.outputDir) { | |
| context = await projectContextForDirectory(path, nbContext, options); | |
| // forceClean signals this is a synthetic project that needs full cleanup | |
| // including removing the .quarto scratch directory after rendering (#13625) | |
| options.forceClean = options.flags.clean !== false; | |
| } |
The change on lines 51-52 now always creates a singleFileProjectContext as fallback:
let context = pContext || (await projectContext(path, nbContext, options)) ||
(await singleFileProjectContext(path, nbContext, options));This means context is never null when the --output-dir check runs on line 57:
if (!context && options.flags?.outputDir) {
The synthetic project creation for --output-dir is now unreachable. The fix could be to check for --output-dir before falling back to singleFileProjectContext, if we really need this fallback. I am unsure about that and its relation to preview fix which is the topic of this PR.
For example
diff --git a/src/command/render/render-shared.ts b/src/command/render/render-shared.ts
--- a/src/command/render/render-shared.ts
+++ b/src/command/render/render-shared.ts
@@ -48,9 +48,7 @@ export async function render(
const nbContext = pContext?.notebookContext || notebookContext();
// determine target context/files
- // let context = await projectContext(path, nbContext, options);
- let context = pContext || (await projectContext(path, nbContext, options)) ||
- (await singleFileProjectContext(path, nbContext, options));
+ let context = pContext || (await projectContext(path, nbContext, options));
// Create a synthetic project when --output-dir is used without a project file
// This creates a temporary .quarto directory to manage the render, which must
@@ -62,6 +60,11 @@ export async function render(
options.forceClean = options.flags.clean !== false;
}
+ // Only fall back to singleFileProjectContext if we don't have a context yet
+ if (!context) {
+ context = await singleFileProjectContext(path, nbContext, options);
+ }
+
// set env var if requested
if (context && options.setProjectDir) {
// FIXME we can't set environment variables like this with asyncs flying around6db3515 to
451f7dc
Compare
Move singleFileProjectContext fallback after the --output-dir check so the synthetic project creation path remains reachable. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
451f7dc to
c3384a5
Compare
This should close a few of our
quarto previewintermittent issues whose symptom is a missingquarto_ipynbfile.See, eg, #12992.