Skip to content

Commit fe95465

Browse files
claude: Fix quarto check julia by loading bundled engines in zero-file context
Fixes the issue where `quarto check julia` was failing with "Invalid value 'julia'" even though Julia is available as a bundled engine extension. The problem: When running commands like `quarto check julia` outside a project directory, no project context exists, so bundled engine extensions were never loaded. The solution: Create a zeroFileProjectContext() that provides just enough structure to discover and register bundled engine extensions when no actual project or file exists. The function initializeProjectContextAndEngines() now falls back to this zero-file context when no project is found. Also changed initializeProjectContextAndEngines() to return Promise<void> instead of Promise<ProjectContext | undefined>, since the name suggests initialization rather than retrieval and both callers ignore the return value. Now `quarto check julia` works both inside and outside project directories. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 92bbe86 commit fe95465

1 file changed

Lines changed: 42 additions & 9 deletions

File tree

‎src/command/command-utils.ts‎

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,39 @@ import { notebookContext } from "../render/notebook/notebook-context.ts";
1010
import { reorderEngines } from "../execute/engine.ts";
1111
import { ProjectContext } from "../project/types.ts";
1212

13+
/**
14+
* Create a minimal "zero-file" project context for loading bundled engine extensions
15+
* when no actual project or file exists.
16+
*
17+
* This is needed for commands like `quarto check julia` that run outside any project
18+
* but still need access to bundled engines. The context provides just enough structure
19+
* to discover and register bundled engine extensions.
20+
*
21+
* @param dir - Directory to use as the base (defaults to current working directory)
22+
* @returns A minimal ProjectContext with bundled engines loaded
23+
*/
24+
async function zeroFileProjectContext(dir?: string): Promise<ProjectContext> {
25+
const { createExtensionContext } = await import(
26+
"../extension/extension.ts"
27+
);
28+
const { resolveEngineExtensions } = await import(
29+
"../project/project-context.ts"
30+
);
31+
32+
const extensionContext = createExtensionContext();
33+
const config = await resolveEngineExtensions(
34+
extensionContext,
35+
{ project: {} },
36+
dir || Deno.cwd(),
37+
);
38+
39+
// Return a minimal project context with the resolved engine config
40+
return {
41+
dir: dir || Deno.cwd(),
42+
config,
43+
} as ProjectContext;
44+
}
45+
1346
/**
1447
* Initialize project context and register external engines from project config.
1548
*
@@ -18,22 +51,22 @@ import { ProjectContext } from "../project/types.ts";
1851
* 2. Creating project context
1952
* 3. Registering external engines via reorderEngines()
2053
*
54+
* If no project is found, a zero-file context is created to load bundled engine
55+
* extensions (like Julia), ensuring they're available for commands like `quarto check julia`.
56+
*
2157
* @param dir - Optional directory path (defaults to current working directory)
22-
* @returns ProjectContext if a project is found, undefined otherwise
2358
*/
2459
export async function initializeProjectContextAndEngines(
2560
dir?: string,
26-
): Promise<ProjectContext | undefined> {
61+
): Promise<void> {
2762
// Initialize YAML intelligence resources (required for project context)
2863
await initYamlIntelligenceResourcesFromFilesystem();
2964

30-
// Load project context if we're in a project directory
31-
const project = await projectContext(dir || Deno.cwd(), notebookContext());
65+
// Load project context if we're in a project directory, or create a zero-file
66+
// context to load bundled engines when no project exists
67+
const context = await projectContext(dir || Deno.cwd(), notebookContext()) ||
68+
await zeroFileProjectContext(dir);
3269

3370
// Register external engines from project config
34-
if (project) {
35-
await reorderEngines(project);
36-
}
37-
38-
return project;
71+
await reorderEngines(context);
3972
}

0 commit comments

Comments
 (0)