Dev Container Chrome wrapper does not recognise Playwright's chrome-linux64 directory

סיכום מבוסס בינה מלאכותית

Ethsim2 reports a bug in the Discourse Dev Container where the Chrome wrapper fails to detect the Chromium executable installed by Playwright. After running pnpm playwright-install, Playwright places Chrome in a chrome-linux64 directory, but the wrapper script at .devcontainer/scripts/chrome_wrapper expects the path to be under chrome-linux. This path mismatch causes google-chrome --version to report that no browser is found, leading to an ArgumentError: Malformed version number string when running QUnit tests.

The reporter provides a workaround involving two steps: first, creating a symlink from chrome-linux64 to chrome-linux, and second, installing missing shared libraries via pnpm exec playwright install-deps chromium. After applying these fixes, the browser is correctly detected, and the QUnit test suite passes with 63 successful tests.

To permanently resolve this, the author suggests updating the Chrome wrapper script to recognize both chrome-linux and chrome-linux64 directory structures. Additionally, they recommend improving error handling in lib/chrome_installed_checker.rb to provide clearer diagnostics when browser version parsing fails.

Problem

While running frontend QUnit tests in a fresh Discourse Dev Container, I encountered an issue with the Chrome wrapper at .devcontainer/scripts/chrome_wrapper.

After installing Chromium using:

pnpm playwright-install

Playwright downloaded Chrome for Testing 156.0.8078.4 into:

/home/discourse/.cache/ms-playwright/chromium-1248/chrome-linux64/chrome

However, the wrapper looks for:

/home/discourse/.cache/ms-playwright/chromium-*/chrome-linux/chrome

Consequently, google-chrome --version returned:

No Chrome/Chromium found at expected location: /home/discourse/.cache/ms-playwright/chromium-*

Running the QUnit tests then failed during browser detection:

ArgumentError: Malformed version number string .
    from lib/chrome_installed_checker.rb:39

Reproduction

  1. Open a fresh Discourse Dev Container.
  2. Run pnpm install.
  3. Run pnpm playwright-install.
  4. Run google-chrome --version.

Expected: The installed Chromium executable is located and its version is displayed.

Actual: The wrapper reports that no Chromium installation was found, despite Playwright having installed it successfully.

Workaround

Creating a symlink resolved the path mismatch:

ln -s chrome-linux64 \
  /home/discourse/.cache/ms-playwright/chromium-1248/chrome-linux

The container also initially lacked the shared libraries required by Chromium. I installed these using:

pnpm exec playwright install-deps chromium

Afterwards, google-chrome --version correctly reported Chrome for Testing 156.0.8078.4.

The affected QUnit test suite subsequently completed successfully, with 63 tests passed and 0 failures.

Suggested improvement

Could .devcontainer/scripts/chrome_wrapper be updated to recognise both chrome-linux/chrome and chrome-linux64/chrome layouts?

It may also be worthwhile to improve the version parsing in lib/chrome_installed_checker.rb, so that invalid browser-version output produces a clearer diagnostic rather than an ArgumentError.