Puppeteer fails on load with shared library libXtst.so.6

Trying to run puppeteer tests on CircleCI (StencilJS project) result in an error where it seems like it can’t find libXtst. I had no problems running this same command on Travis:

[ ERROR ]  Failed to launch chrome!
           /home/circleci/project/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome:
           error while loading shared libraries: libXtst.so.6: cannot open
           shared object file: No such file or directory TROUBLESHOOTING:
           https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
           Error: Failed to launch chrome!
           /home/circleci/project/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome:
           error while loading shared libraries: libXtst.so.6: cannot open
           shared object file: No such file or directory TROUBLESHOOTING:
           https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
           at onClose
           (/home/circleci/project/node_modules/puppeteer/lib/Launcher.js:342:14)
           at Interface.helper.addEventListener
           (/home/circleci/project/node_modules/puppeteer/lib/Launcher.js:331:50)
           at Interface.emit (events.js:203:15) at Interface.close
           (readline.js:397:8) at Socket.onend (readline.js:173:10) at
           Socket.emit (events.js:203:15) at endReadableNT
           (_stream_readable.js:1129:12) at process._tickCallback
           (internal/process/next_tick.js:63:19)

And here’s my config.yml (with the jobs that were running fine removed):

version: 2.1

defaults: &defaults
  docker:
    - image: circleci/node:10.16.0
  environment:
    - NODE_ENV: development # CircleCI needs devDeps

commands:
  # npm install
  setup:
    steps:
      - checkout
      - restore_cache:
          keys:
            - node_modules-{{ checksum "package.json" }}
            - node_modules-
      - run: npm install
      - save_cache:
          paths:
            - node_modules
          key: node_modules-{{ checksum "package.json" }}
      - run: npm run prepare-docs

  # Lint & test
  test:
    <<: *defaults
    steps:
      - setup
      - run: npm run lint && npm test

workflows:
  version: 2

  # Normal workflow for untagged PRs
  untagged:
    jobs:
      - test

Edit: this seems to be related to missing dependencies on Linux, at least according to the Puppeteer troubleshooting guide. This problem seems to be unique to CircleCI; I’m running the exact same Puppeteer command on Travis with no problem. How do I go about installing a missing dependency from a CircleCI image?

In my opinion, this is not exactly true, or at any rate that statement may lead to a misunderstanding of the problem. CI machines (Travis, GitLab, Bitbucket Pipelines, CircleCI, etc) are just Linux machines. They will come in different flavours and Linux distributions, but broadly they are just ordinary build servers (perhaps with a dash of their own software).

An important corollary is that the fix for a build problem is generally the same as if you have the same problem locally, on a dev Linux laptop. To fix this, I’d look at whether there were any problems with the npm install, and I might also be inclined to fire up a post-fail SSH session to see if the tests can run at that point (sometimes giving slow listeners enough time to boot up is all that you need).

Of course, there could be a missing library that is not due to missing deps in the NPM modules specified. To fix this, you could use an SSH session to try Apt/Yum etc to install that library from the upstream repo (e.g. in apt I would do apt-cache search libXtst). If you find something, you could try installing it before calling the tests.

Or, indeed, you could try installing the lists of dependencies in your link.

Update: I was able to find this orb, and copied the sudo apt-get install -yq … bit that installed everything necessary: https://circleci.com/orbs/registry/orb/threetreeslight/puppeteer

1 Like