Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ All changes included in 1.7:
- ([#11643](https://github.com/quarto-dev/quarto-cli/issues/11643)): Improve highlighting of nested code block inside markdown code block, i.e. using ` ```{{python}} ` or ` ```python ` inside ` ````markdown` fenced code block.
- ([fb38eb5](https://github.com/quarto-dev/quarto-cli/commit/fb38eb56c11e09f44cef58fd3b697ff24bb5a3f3)) Use the `latest` parser for Acorn when analyzing JS code imported from OJS blocks.
- ([#10532](https://github.com/quarto-dev/quarto-cli/issues/10532)): Quarto changed default of `--headless=old` to `--headless` as [Chrome 132 has removed old headless mode](https://developer.chrome.com/blog/removing-headless-old-from-chrome) and only support new mode. For using old mode, `QUARTO_CHROMIUM` could be set to a [new `chrome-headless-shell` binary](https://developer.chrome.com/blog/chrome-headless-shell) or too an older chrome version (between 128 and 132) and `QUARTO_CHROMIUM_HEADLESS_MODE` set to `old` for using old headless mode with that compatabitle version.
- ([#10961](https://github.com/quarto-dev/quarto-cli/issues/10961)): Add more information on which Chrome Headless will be used in `quarto check install`. This is helpful to help debug mermaid issues.
41 changes: 40 additions & 1 deletion src/command/check/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { typstBinaryPath } from "../../core/typst.ts";
import { quartoCacheDir } from "../../core/appdirs.ts";
import { isWindows } from "../../deno_ral/platform.ts";
import { makeStringEnumTypeEnforcer } from "../../typing/dynamic.ts";
import { findChrome } from "../../core/puppeteer.ts";

export const kTargets = [
"install",
Expand Down Expand Up @@ -212,11 +213,12 @@ async function checkInstall(services: RenderServices) {
info("");
const toolsMessage = "Checking tools....................";
const toolsOutput: string[] = [];
let tools: Awaited<ReturnType<typeof allTools>>;
await withSpinner({
message: toolsMessage,
doneMessage: toolsMessage + "OK",
}, async () => {
const tools = await allTools();
tools = await allTools();

for (const tool of tools.installed) {
const version = await tool.installedVersion() || "(external install)";
Expand Down Expand Up @@ -260,6 +262,43 @@ async function checkInstall(services: RenderServices) {
latexOutput.forEach((out) => info(out));
info("");

const chromeHeadlessMessage = "Checking Chrome Headless....................";
const chromeHeadlessOutput: string[] = [];
await withSpinner({
message: chromeHeadlessMessage,
doneMessage: chromeHeadlessMessage + "OK",
}, async () => {
const chromeDetected = await findChrome();
const chromiumQuarto = tools.installed.find((tool) =>
tool.name === "chromium"
);
if (chromeDetected.path !== undefined) {
chromeHeadlessOutput.push(`${kIndent}Using: Chrome found on system`);
chromeHeadlessOutput.push(
`${kIndent}Path: ${chromeDetected.path}`,
);
if (chromeDetected.source) {
chromeHeadlessOutput.push(`${kIndent}Source: ${chromeDetected.source}`);
}
} else if (chromiumQuarto !== undefined) {
chromeHeadlessOutput.push(
`${kIndent}Using: Chromium installed by Quarto`,
);
if (chromiumQuarto?.binDir) {
chromeHeadlessOutput.push(
`${kIndent}Path: ${chromiumQuarto?.binDir}`,
);
}
chromeHeadlessOutput.push(
`${kIndent}Version: ${chromiumQuarto.installedVersion}`,
);
} else {
chromeHeadlessOutput.push(`${kIndent}Chrome: (not detected)`);
}
});
chromeHeadlessOutput.forEach((out) => info(out));
info("");

const kMessage = "Checking basic markdown render....";
await withSpinner({
message: kMessage,
Expand Down
28 changes: 22 additions & 6 deletions src/core/puppeteer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,21 @@ export async function withHeadlessBrowser<T>(
}
}

async function findChrome(): Promise<string | undefined> {
interface ChromeInfo {
path: string | undefined;
source: string | undefined;
}

export async function findChrome(): Promise<ChromeInfo> {
let path;
let source;
// First check env var and use this path if specified
const envPath = Deno.env.get("QUARTO_CHROMIUM");
if (envPath) {
debug("[CHROMIUM] Using path specified in QUARTO_CHROMIUM");
if (safeExistsSync(envPath)) {
debug(`[CHROMIUM] Found at ${envPath}, and will be used.`);
return envPath;
return { path: envPath, source: "QUARTO_CHROMIUM" };
} else {
debug(
`[CHROMIUM] Not found at ${envPath}. Check your environment variable valye. Searching now for another binary.`,
Expand All @@ -222,6 +228,7 @@ async function findChrome(): Promise<string | undefined> {
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
];
path = programs.find(safeExistsSync);
source = "MacOS known location";
} else if (isWindows) {
// Try the HKLM key
const programs = ["chrome.exe", "msedge.exe"];
Expand All @@ -231,7 +238,10 @@ async function findChrome(): Promise<string | undefined> {
programs[i],
"(Default)",
);
if (path && safeExistsSync(path)) break;
if (path && safeExistsSync(path)) {
source = "Windows Registry";
break;
}
}

// Try the HKCR key
Expand All @@ -244,7 +254,10 @@ async function findChrome(): Promise<string | undefined> {
);
path = path?.match(/"(.*)"/);
path = path ? path[1] : undefined;
if (path && existsSync(path)) break;
if (path && existsSync(path)) {
source = "Windows Registry";
break;
}
}
}
} else {
Expand All @@ -254,14 +267,17 @@ async function findChrome(): Promise<string | undefined> {
if (!path) {
path = await which("chromium-browser");
}
if (path && existsSync(path)) {
source = "PATH";
}
}
if (path) {
debug("[CHROMIUM] Found Chromium on OS known location");
debug(`[CHROMIUM] Path: ${path}`);
} else {
debug("[CHROMIUM] Chromium not found on OS known location");
}
return path;
return { path: path, source: source };
}

export async function getBrowserExecutablePath() {
Expand All @@ -272,7 +288,7 @@ export async function getBrowserExecutablePath() {
let executablePath: string | undefined = undefined;

if (executablePath === undefined) {
executablePath = await findChrome();
executablePath = (await findChrome()).path;
}

if (executablePath === undefined && availableRevisions.length > 0) {
Expand Down
Loading