Build fails because executable doesn't exist

We are running a Starlight documentation site, which is based on Astro. This project is part of a larger monorepo which manages dependencies via pnpm.

In order to properly support Mermaid diagrams in markdown, we added the remark-mermaid plugin (GitHub - remcohaszing/remark-mermaidjs: A remark plugin to render mermaid diagrams using playwright). This plugin has a dependency on Playwright, and the docs stated that Playwright needs to be installed via npx playwright install --with-deps chromium, in order to get it to work.

We added this to the build command, such that our build command looks like this: pnpm install --no-frozen-lockfile && pnpm dlx playwright install chromium && pnpm build

Upon deployment however, the build step fails because although Chromium gets downloaded successfully, somehow Astro keeps getting pointed to an older version of the executable which does not exist. We have tried by clearing cache and rerunning the deploy, that didn’t work. We tried to uninstall and reinstall Playwright but Netlify hated that and failed the build instantly. Anyone have any more suggestions or ideas?

Deploy logs as follows:

5:22:39 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
5:22:22 PM: Netlify Build
5:22:22 PM: ────────────────────────────────────────────────────────────────
5:22:22 PM: ​
5:22:22 PM: ❯ Version
5:22:22 PM: @netlify/build 29.21.1
5:22:22 PM: ​
5:22:22 PM: ❯ Flags
5:22:22 PM: baseRelDir: true
5:22:22 PM: buildId: 6509ae7454f949000874b66b
5:22:22 PM: deployId: 6509ae7454f949000874b66d
5:22:22 PM: ​
5:22:22 PM: ❯ Current directory
5:22:22 PM: /opt/build/repo/packages/documentation
5:22:22 PM: ​
5:22:22 PM: ❯ Config file
5:22:22 PM: /opt/build/repo/packages/documentation/netlify.toml
5:22:22 PM: ​
5:22:22 PM: ❯ Context
5:22:22 PM: deploy-preview
5:22:22 PM: ​
5:22:22 PM: build.command from netlify.toml
5:22:22 PM: ────────────────────────────────────────────────────────────────
5:22:22 PM: ​
5:22:22 PM: $ pnpm install --no-frozen-lockfile && npx playwright install chromium && pnpm build
5:22:23 PM: Scope: all 8 workspace projects
5:22:24 PM: Done in 1.4s
5:22:27 PM: npm WARN exec The following package was not found and will be installed: playwright@1.38.0
5:22:28 PM: ╔═══════════════════════════════════════════════════════════════════════════════╗
5:22:28 PM: ║ WARNING: It looks like you are running 'npx playwright install' without first ║
5:22:28 PM: ║ installing your project's dependencies. ║
║ ║
5:22:28 PM: ║ To avoid unexpected behavior, please install your dependencies first, and ║
5:22:28 PM: ║ then run Playwright's install command: ║
║ ║
5:22:28 PM: ║ npm install ║
5:22:28 PM: ║ npx playwright install ║
5:22:28 PM: ║ ║
5:22:28 PM: ║ If your project does not yet depend on Playwright, first install the ║
5:22:28 PM: ║ applicable npm package (most commonly @playwright/test), and ║
5:22:28 PM: ║ then run Playwright's install command to download the browsers: ║
║ ║
5:22:28 PM: ║ npm install @playwright/test ║
5:22:28 PM: ║ npx playwright install ║
5:22:28 PM: ║ ║
5:22:28 PM: ╚═══════════════════════════════════════════════════════════════════════════════╝
5:22:28 PM: Downloading Chromium 117.0.5938.62 (playwright build v1080) from https://playwright.azureedge.net/builds/chromium/1080/chromium-linux.zip
5:22:28 PM: 0% of 153.1 Mb
5:22:29 PM: ■■■■■■■■ 10% of 153.1 Mb
5:22:29 PM: ■■■■■■■■■■■■■■■■ 20% of 153.1 Mb
5:22:29 PM: ■■■■■■■■■■■■■■■■■■■■■■■■ 30% of 153.1 Mb
5:22:29 PM: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 40% of 153.1 Mb
5:22:29 PM: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 50% of 153.1 Mb
5:22:29 PM: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 60% of 153.1 Mb
5:22:29 PM: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 70% of 153.1 Mb
5:22:29 PM: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 80% of 153.1 Mb
5:22:29 PM: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 90% of 153.1 Mb
5:22:29 PM: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 100% of 153.1 Mb
5:22:31 PM: Chromium 117.0.5938.62 (playwright build v1080) downloaded to /opt/buildhome/.cache/ms-playwright/chromium-1080
5:22:31 PM: Downloading FFMPEG playwright build v1009 from https://playwright.azureedge.net/builds/ffmpeg/1009/ffmpeg-linux.zip
5:22:32 PM: 0% of 2.6 Mb
5:22:32 PM: ■■■■■■■■ 10% of 2.6 Mb
5:22:32 PM: ■■■■■■■■■■■■■■■■ 20% of 2.6 Mb
5:22:32 PM: ■■■■■■■■■■■■■■■■■■■■■■■■ 30% of 2.6 Mb
5:22:32 PM: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 40% of 2.6 Mb
5:22:32 PM: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 50% of 2.6 Mb
5:22:32 PM: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 60% of 2.6 Mb
5:22:32 PM: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 70% of 2.6 Mb
5:22:32 PM: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 80% of 2.6 Mb
5:22:32 PM: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 90% of 2.6 Mb
5:22:32 PM: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 100% of 2.6 Mb
5:22:32 PM: FFMPEG playwright build v1009 downloaded to /opt/buildhome/.cache/ms-playwright/ffmpeg-1009
5:22:32 PM: > documentation@0.0.1 build /opt/build/repo/packages/documentation
5:22:32 PM: > astro build
5:22:34 PM: 02:22:34 PM [content] Types generated 243ms
5:22:34 PM: Subscriptions are not supported yet
5:22:34 PM: Subscriptions are not supported yet
5:22:34 PM: 02:22:34 PM [build] output target: static
5:22:34 PM: 02:22:34 PM [build] Collecting build info...
5:22:34 PM: 02:22:34 PM [build] Completed in 378ms.
5:22:34 PM: 02:22:34 PM [build] Building static entrypoints...
5:22:37 PM: The language gql doesn't exist, falling back to plaintext.
browserType.launch: Executable doesn't exist at /opt/buildhome/.cache/ms-playwright/chromium-1076/chrome-linux/chrome
╔═════════════════════════════════════════════════════════════════════════╗
5:22:37 PM: ║ Looks like Playwright Test or Playwright was just installed or updated. ║
5:22:37 PM: ║ Please run the following command to download new browsers: ║
5:22:37 PM: ║ ║
5:22:37 PM: ║ npx playwright install ║
5:22:37 PM: ║ ║
5:22:37 PM: ║ <3 Playwright Team ║
5:22:37 PM: ╚═════════════════════════════════════════════════════════════════════════╝
5:22:37 PM: at file:///opt/build/repo/node_modules/.pnpm/mermaid-isomorphic@2.1.0/node_modules/mermaid-isomorphic/index.js:90:39
5:22:37 PM: at transformer (file:///opt/build/repo/node_modules/.pnpm/remark-mermaidjs@5.0.2/node_modules/remark-mermaidjs/index.js:18:31)
5:22:37 PM: at wrapped (file:///opt/build/repo/node_modules/.pnpm/trough@2.1.0/node_modules/trough/index.js:115:27)
5:22:37 PM: at next (file:///opt/build/repo/node_modules/.pnpm/trough@2.1.0/node_modules/trough/index.js:65:23)
5:22:37 PM: at done (file:///opt/build/repo/node_modules/.pnpm/trough@2.1.0/node_modules/trough/index.js:148:7)
5:22:37 PM: at then (file:///opt/build/repo/node_modules/.pnpm/trough@2.1.0/node_modules/trough/index.js:158:5)
5:22:37 PM: at wrapped (file:///opt/build/repo/node_modules/.pnpm/trough@2.1.0/node_modules/trough/index.js:136:9)
5:22:37 PM: at next (file:///opt/build/repo/node_modules/.pnpm/trough@2.1.0/node_modules/trough/index.js:65:23)
5:22:37 PM: at Object.run (file:///opt/build/repo/node_modules/.pnpm/trough@2.1.0/node_modules/trough/index.js:36:5)
5:22:37 PM: at executor (file:///opt/build/repo/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:321:20)
5:22:37 PM: at Function.run (file:///opt/build/repo/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:312:5)
5:22:37 PM: at executor (file:///opt/build/repo/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:393:17)
5:22:37 PM: at Function.process (file:///opt/build/repo/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:380:14)
5:22:37 PM: at Object.render (file:///opt/build/repo/node_modules/.pnpm/@astrojs+markdown-remark@3.2.0_astro@3.1.1/node_modules/@astrojs/markdown-remark/dist/index.js:89:35)
5:22:37 PM: at Object.load (file:///opt/build/repo/node_modules/.pnpm/astro@3.1.1/node_modules/astro/dist/vite-plugin-markdown/index.js:59:46)
5:22:37 PM: at async PluginDriver.hookFirstAndGetPlugin (file:///opt/build/repo/node_modules/.pnpm/rollup@3.28.1/node_modules/rollup/dist/es/shared/node-entry.js:25361:28)
5:22:37 PM: at async file:///opt/build/repo/node_modules/.pnpm/rollup@3.28.1/node_modules/rollup/dist/es/shared/node-entry.js:24529:75
5:22:37 PM: at async Queue.work (file:///opt/build/repo/node_modules/.pnpm/rollup@3.28.1/node_modules/rollup/dist/es/shared/node-entry.js:25571:32) {
5:22:37 PM: name: 'Error'
5:22:37 PM: }
5:22:37 PM: [astro:markdown] Could not load /opt/build/repo/packages/documentation/src/content/docs/integration/event-handlers.md (imported by src/content/docs/integration/event-handlers.md?astroPropagatedAssets): Failed to parse Markdown file /opt/build/repo/packages/documentation/src/content/docs/integration/event-handlers.md:
5:22:37 PM: browserType.launch: Executable doesn't exist at /opt/buildhome/.cache/ms-playwright/chromium-1076/chrome-linux/chrome
╔═════════════════════════════════════════════════════════════════════════╗
5:22:37 PM: ║ Looks like Playwright Test or Playwright was just installed or updated. ║
5:22:37 PM: ║ Please run the following command to download new browsers: ║
5:22:37 PM: ║ ║
5:22:37 PM: ║ npx playwright install ║
5:22:37 PM: ║ ║
5:22:37 PM: ║ <3 Playwright Team ║
5:22:37 PM: ╚═════════════════════════════════════════════════════════════════════════╝
5:22:37 PM: error Could not load /opt/build/repo/packages/documentation/src/content/docs/integration/event-handlers.md (imported by src/content/docs/integration/event-handlers.md?astroPropagatedAssets): Failed to parse Markdown file /opt/build/repo/packages/documentation/src/content/docs/integration/event-handlers.md:
5:22:37 PM: browserType.launch: Executable doesn't exist at /opt/buildhome/.cache/ms-playwright/chromium-1076/chrome-linux/chrome
╔═════════════════════════════════════════════════════════════════════════╗
5:22:37 PM: ║ Looks like Playwright Test or Playwright was just installed or updated. ║
5:22:37 PM: ║ Please run the following command to download new browsers: ║
5:22:37 PM: ║ ║
5:22:37 PM: ║ npx playwright install ║
5:22:37 PM: ║ ║
5:22:37 PM: ║ <3 Playwright Team ║
5:22:37 PM: ╚═════════════════════════════════════════════════════════════════════════╝
5:22:37 PM: Hint:
5:22:37 PM: Browser APIs are not available on the server.
5:22:37 PM: If the code is in a framework component, try to access these objects after rendering using lifecycle methods or use a `client:only` directive to make the component exclusively run on the client.
5:22:37 PM: See https://docs.astro.build/en/guides/troubleshooting/#document-or-window-is-not-defined for more information.
5:22:37 PM:
5:22:37 PM: File:
5:22:37 PM: /opt/build/repo/node_modules/.pnpm/mermaid-isomorphic@2.1.0/node_modules/mermaid-isomorphic/index.js:90:39
5:22:37 PM: Code:
5:22:37 PM: 89 if (!browserPromise) {
5:22:37 PM: > 90 browserPromise = browser?.launch(launchOptions);
5:22:37 PM: ^
5:22:37 PM: 91 }
5:22:37 PM: 92 const browserInstance = await browserPromise;
5:22:37 PM: 93 let page;
5:22:37 PM: Stacktrace:
5:22:37 PM: browserType.launch: Executable doesn't exist at /opt/buildhome/.cache/ms-playwright/chromium-1076/chrome-linux/chrome
╔═════════════════════════════════════════════════════════════════════════╗
5:22:37 PM: ║ Looks like Playwright Test or Playwright was just installed or updated. ║
5:22:37 PM: ║ Please run the following command to download new browsers: ║
5:22:37 PM: ║ ║
5:22:37 PM: ║ npx playwright install ║
5:22:37 PM: ║ ║
5:22:37 PM: ║ <3 Playwright Team ║
5:22:37 PM: ╚═════════════════════════════════════════════════════════════════════════╝
5:22:37 PM: at file:///opt/build/repo/node_modules/.pnpm/mermaid-isomorphic@2.1.0/node_modules/mermaid-isomorphic/index.js:90:39
5:22:37 PM: at transformer (file:///opt/build/repo/node_modules/.pnpm/remark-mermaidjs@5.0.2/node_modules/remark-mermaidjs/index.js:18:31)
5:22:37 PM: at wrapped (file:///opt/build/repo/node_modules/.pnpm/trough@2.1.0/node_modules/trough/index.js:115:27)
5:22:37 PM: at next (file:///opt/build/repo/node_modules/.pnpm/trough@2.1.0/node_modules/trough/index.js:65:23)
5:22:37 PM: at done (file:///opt/build/repo/node_modules/.pnpm/trough@2.1.0/node_modules/trough/index.js:148:7)
5:22:37 PM: at then (file:///opt/build/repo/node_modules/.pnpm/trough@2.1.0/node_modules/trough/index.js:158:5)
5:22:37 PM: at wrapped (file:///opt/build/repo/node_modules/.pnpm/trough@2.1.0/node_modules/trough/index.js:136:9)
5:22:37 PM: at next (file:///opt/build/repo/node_modules/.pnpm/trough@2.1.0/node_modules/trough/index.js:65:23)
5:22:37 PM: at Object.run (file:///opt/build/repo/node_modules/.pnpm/trough@2.1.0/node_modules/trough/index.js:36:5)
5:22:37 PM: at executor (file:///opt/build/repo/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:321:20)
5:22:37 PM: at Function.run (file:///opt/build/repo/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:312:5)
5:22:37 PM: at executor (file:///opt/build/repo/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:393:17)
5:22:37 PM: at Function.process (file:///opt/build/repo/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:380:14)
5:22:37 PM: at Object.render (file:///opt/build/repo/node_modules/.pnpm/@astrojs+markdown-remark@3.2.0_astro@3.1.1/node_modules/@astrojs/markdown-remark/dist/index.js:89:35)
5:22:37 PM: at Object.load (file:///opt/build/repo/node_modules/.pnpm/astro@3.1.1/node_modules/astro/dist/vite-plugin-markdown/index.js:59:46)
5:22:37 PM: at async PluginDriver.hookFirstAndGetPlugin (file:///opt/build/repo/node_modules/.pnpm/rollup@3.28.1/node_modules/rollup/dist/es/shared/node-entry.js:25361:28)
5:22:37 PM: at async file:///opt/build/repo/node_modules/.pnpm/rollup@3.28.1/node_modules/rollup/dist/es/shared/node-entry.js:24529:75
5:22:37 PM: at async Queue.work (file:///opt/build/repo/node_modules/.pnpm/rollup@3.28.1/node_modules/rollup/dist/es/shared/node-entry.js:25571:32)
5:22:37 PM: ELIFECYCLE Command failed with exit code 1. (https://ntl.fyi/exit-code-1)
5:22:37 PM: ​
5:22:37 PM: build.command failed
5:22:37 PM: ────────────────────────────────────────────────────────────────
5:22:37 PM: ​
5:22:37 PM: Error message
5:22:37 PM: Command failed with exit code 1: pnpm install --no-frozen-lockfile && npx playwright install chromium && pnpm build (https://ntl.fyi/exit-code-1)
5:22:37 PM: ​
5:22:37 PM: Error location
5:22:37 PM: In build.command from netlify.toml:
5:22:37 PM: pnpm install --no-frozen-lockfile && npx playwright install chromium && pnpm build
5:22:37 PM: ​
5:22:37 PM: Resolved config
5:22:37 PM: build:
5:22:37 PM: base: /opt/build/repo/packages/documentation
5:22:37 PM: command: pnpm install --no-frozen-lockfile && npx playwright install chromium && pnpm build
5:22:37 PM: commandOrigin: config
5:22:37 PM: environment:
5:22:37 PM: - NODE_VERSION
5:22:37 PM: - REVIEW_ID
5:22:37 PM: publish: /opt/build/repo/packages/documentation/build
5:22:37 PM: publishOrigin: config
5:22:39 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:22:39 PM: Failing build: Failed to build site
5:22:40 PM: Finished processing build request in 58.356s

Any particular reason to run pnpm install yourself instead of letting Netlify handle the installation? Also, what happens if you run

instead of your custom command?

Running just npx playwright install --with-deps chromium (which is the instructions in the README also resulted in some errors, so we changed it to remove the --with-deps), errored because it said dependencies had not been installed yet. Anyway, it all magically worked without us figuring out what the problem was.

One of our engineers suggested that maybe Netlify’s cache resolved itself or something. I cannot in clear conscience state what the answer is but this problem seems to be resolved. For now.

thanks for writing back in with this update.