Skip to content

Commit a900fc3

Browse files
committed
no sandbox for CI
1 parent 523477d commit a900fc3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/myst-cli/src/transforms/mermaid.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,21 @@ async function renderMermaidToBase64(
5050
}
5151

5252
try {
53+
// Create puppeteer config file for CI environments
54+
// See https://github.com/mermaid-js/mermaid-cli/blob/master/docs/linux-sandbox-issue.md
55+
const useNoSandbox = process.env.MERMAID_NO_SANDBOX === 'true' || process.env.CI === 'true';
56+
let puppeteerConfigFlag = '';
57+
58+
if (useNoSandbox) {
59+
const puppeteerConfigPath = path.join(tempFolder, 'puppeteer-config.json');
60+
const puppeteerConfig = { args: ['--no-sandbox'] };
61+
await fs.writeFile(puppeteerConfigPath, JSON.stringify(puppeteerConfig, null, 2));
62+
puppeteerConfigFlag = ` -p "${puppeteerConfigPath}"`;
63+
}
64+
5365
// Render using Mermaid CLI with stdin input
5466
await execAsync(
55-
`echo '${mermaidCode.replace(/'/g, "'\"'\"'")}' | mmdc -i - -o "${outputFile}" -t ${theme} -b transparent`,
67+
`echo '${mermaidCode.replace(/'/g, "'\"'\"'")}' | mmdc -i - -o "${outputFile}" -t ${theme} -b transparent${puppeteerConfigFlag}`,
5668
);
5769

5870
// Read the generated file

0 commit comments

Comments
 (0)