Skip to content

Fix preview of single-file Julia documents#14210

Merged
gordonwoodhull merged 2 commits intomainfrom
bugfix/14208
Mar 13, 2026
Merged

Fix preview of single-file Julia documents#14210
gordonwoodhull merged 2 commits intomainfrom
bugfix/14208

Conversation

@gordonwoodhull
Copy link
Contributor

@gordonwoodhull gordonwoodhull commented Mar 13, 2026

Engine extensions (like the bundled Julia engine) were only loaded in singleFileProjectContext when renderOptions was provided. The preview command creates the project context before render services exist, so engine extensions were never discovered for single files. This caused Jupyter to win the language claim for Julia code blocks.

Now engine extensions are always resolved, using a fresh extension context as fallback when renderOptions is absent — matching the pattern used by projectContext.

Fixes #14208

…ulia engine

Engine extensions (like the bundled Julia engine) were only loaded in
singleFileProjectContext when renderOptions was provided. The preview
command creates the project context before render services exist, so
engine extensions were never discovered for single files. This caused
Jupyter to win the language claim for Julia code blocks.

Now engine extensions are always resolved, using a fresh extension
context as fallback when renderOptions is absent — matching the pattern
used by projectContext.

Fixes #14208
@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Mar 13, 2026

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.

@gordonwoodhull gordonwoodhull marked this pull request as draft March 13, 2026 16:14
@gordonwoodhull gordonwoodhull marked this pull request as ready for review March 13, 2026 16:24
@cderv
Copy link
Collaborator

cderv commented Mar 13, 2026

The fix looks correct to me — I arrived at the same approach independently.

For testing, since preview is hard to test end-to-end, a unit test on singleFileProjectContext works well. The idea is to call it without renderOptions (the preview code path) and assert that engine extensions are still resolved:

// tests/unit/project/single-file-engine-resolution.test.ts
import { unitTest } from "../../test.ts";
import { assert } from "testing/asserts";
import { join } from "../../../src/deno_ral/path.ts";
import { singleFileProjectContext } from "../../../src/project/types/single-file/single-file.ts";
import { notebookContext } from "../../../src/render/notebook/notebook-context.ts";
import { initYamlIntelligenceResourcesFromFilesystem } from "../../../src/core/schema/utils.ts";

unitTest(
  "singleFileProjectContext resolves engine extensions without renderOptions",
  async () => {
    await initYamlIntelligenceResourcesFromFilesystem();

    const tmpDir = Deno.makeTempDirSync({ prefix: "quarto-test" });
    const file = join(tmpDir, "test.qmd");
    Deno.writeTextFileSync(
      file,
      "---\ntitle: test\nengine: julia\n---\n",
    );

    try {
      const nbContext = notebookContext();
      const project = await singleFileProjectContext(file, nbContext);

      assert(
        project.config !== undefined,
        "config should be initialized even without renderOptions",
      );
      assert(
        Array.isArray(project.config?.engines) &&
          project.config.engines.length > 0,
        "engine extensions should be resolved (bundled engines discovered)",
      );
    } finally {
      Deno.removeSync(tmpDir, { recursive: true });
    }
  },
);

This fails before the fix (config is undefined) and passes after. The key insight is that initYamlIntelligenceResourcesFromFilesystem() is needed because createExtensionContext() reads extension schemas.

…derOptions

Verifies that singleFileProjectContext discovers bundled engine
extensions (e.g. Julia) even when called without renderOptions,
which is the code path used by quarto preview.

Co-authored-by: Christophe Dervieux <cderv@users.noreply.github.com>
@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Mar 13, 2026

Thanks @cderv, added.

@gordonwoodhull gordonwoodhull merged commit 00a68f3 into main Mar 13, 2026
51 checks passed
@gordonwoodhull gordonwoodhull deleted the bugfix/14208 branch March 13, 2026 17:38
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.

VS Code Quarto preview uses Jupyter Julia kernel instead of native engine: julia

3 participants