npm test says Cannot start ChromeHeadless

Hi, I would like to execute an Action with "npm test ". But it fails. I get these error messages:

> ng test --browsers=ChromeHeadlessNoSandbox --watch=false
02 05 2020 13:34:06.719:INFO [karma-server]: Karma v4.4.1 server started at http://0.0.0.0:9876/
02 05 2020 13:34:06.721:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox with concurrency unlimited
02 05 2020 13:34:06.725:INFO [launcher]: Starting browser ChromeHeadless
02 05 2020 13:34:07.190:ERROR [launcher]: Cannot start ChromeHeadless
/home/runner/work/Sprinter/Sprinter/node_modules/puppeteer/.local-chromium/linux-737027/chrome-linux/chrome: error while loading shared libraries: libgbm.so.1: cannot open shared object file: No such file or directory
02 05 2020 13:34:07.191:ERROR [launcher]: ChromeHeadless stdout:
02 05 2020 13:34:07.192:ERROR [launcher]: ChromeHeadless stderr: /home/runner/work/Sprinter/Sprinter/node_modules/puppeteer/.local-chromium/linux-737027/chrome-linux/chrome: error while loading shared libraries: libgbm.so.1: cannot open shared object file: No such file or directory
02 05 2020 13:34:07.213:INFO [launcher]: Trying to start ChromeHeadless again (1/2).
02 05 2020 13:34:07.253:ERROR [launcher]: Cannot start ChromeHeadless
/home/runner/work/Sprinter/Sprinter/node_modules/puppeteer/.local-chromium/linux-737027/chrome-linux/chrome: error while loading shared libraries: libgbm.so.1: cannot open shared object file: No such file or directory
02 05 2020 13:34:07.253:ERROR [launcher]: ChromeHeadless stdout:
02 05 2020 13:34:07.254:ERROR [launcher]: ChromeHeadless stderr: /home/runner/work/Sprinter/Sprinter/node_modules/puppeteer/.local-chromium/linux-737027/chrome-linux/chrome: error while loading shared libraries: libgbm.so.1: cannot open shared object file: No such file or directory
02 05 2020 13:34:07.911:INFO [launcher]: Trying to start ChromeHeadless again (2/2).
02 05 2020 13:34:07.960:ERROR [launcher]: Cannot start ChromeHeadless
/home/runner/work/Sprinter/Sprinter/node_modules/puppeteer/.local-chromium/linux-737027/chrome-linux/chrome: error while loading shared libraries: libgbm.so.1: cannot open shared object file: No such file or directory
02 05 2020 13:34:07.961:ERROR [launcher]: ChromeHeadless stdout:
02 05 2020 13:34:07.962:ERROR [launcher]: ChromeHeadless stderr: /home/runner/work/Sprinter/Sprinter/node_modules/puppeteer/.local-chromium/linux-737027/chrome-linux/chrome: error while loading shared libraries: libgbm.so.1: cannot open shared object file: No such file or directory
02 05 2020 13:34:07.973:ERROR [launcher]: ChromeHeadless failed 2 times (cannot start). Giving up.
npm ERR! Test failed. See above for more details.

What do I have to do? Thanks for any help!

Okay I found this:

https://medium.com/@ssmak/how-to-fix-puppetteer-error-while-loading-shared-libraries-libx11-xcb-so-1-c1918b75acc3

Seems that the ubuntu-latest image is missing some required libraries to run with latest puppeteer version.  Is there a way to add these libs or is there a way to tell GitHub to extend the ubuntu-latest?

@mwalter ,

This is an known issue has been reported by many users.

To solve this problem, you can try the below commands in your workflow (you also can reference puppeteer/puppeteer#5661):

sudo apt-get update
sudo apt-get install -y libgbm-dev

And the appropriate engineering team of the runner’s virtual environments has been fixing this problem (see actions/virtual-environments#734).

If you have any issue about the virtual environments of GitHub-hosted runners, you can open or follow a issue in the actions/virtual-environments repository.

1 Like

Thanks a lot for the link and solution!

it solved my problem as well