[Feedback] Puppeteer no longer works out-of-the-box in new Ubuntu 20.04-based Default Codespaces

In the original Stretch-based image, Puppeteer can be installed and used right out-of-the-box. However with the Default Codespaces “universal” image now based on Ubuntu 20.04, it no longer works.

First, it errors out:

/home/codespace/workspace/timelapse/main.js:120
  throw up
  ^

Error: Failed to launch the browser process!
/home/codespace/workspace/timelapse/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: error while loading shared libraries: libX11-xcb.so.1: cannot open shared object file: No such file or directory


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/home/codespace/workspace/timelapse/node_modules/puppeteer/lib/Launcher.js:750:14)
    at Interface.<anonymous> (/home/codespace/workspace/timelapse/node_modules/puppeteer/lib/Launcher.js:739:50)
    at Interface.emit (events.js:327:22)
    at Interface.close (readline.js:424:8)
    at Socket.onend (readline.js:202:10)
    at Socket.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

I tried to sudo apt install chromium-browser. This causes Chromium to be installed but still cannot launch either Chromium or Puppeteer because it is now a snap-only package and the required deps are no longer installed via apt.

One solution I tried is to revert back to Stretch-based images. This works but starting a new Codespace takes almost 10 minutes.

This seems to be the problem with Codespaces’ image, because I also confirmed that GitHub Actions with runs-on: ubuntu-20.04 can also run Puppeteer out-of-the-box.

It would be great if the new Ubuntu 20.04-based image could run Puppeteer out-of-the-box without the need for any extra configuration like before.

Thanks for raising the issue. Likely the new image has some missing dependencies. See here for a complete list for Ubuntu and Debian:

puppeteer/troubleshooting.md at main · puppeteer/puppeteer (github.com)

You should be able to resolve this by running apt to install the referenced list (though only a subset of these will be missing). Here’s a one-liner to do that:

sudo apt-get update && sudo apt-get install -y --no-install-recommends ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils

We can look at what impact adding them to the new image by default.

1 Like