puppeteer: Headless Chromium with Puppeteer doesn't work on Amazon Linux AMI
Environment:
- Amazon Linux AMI version 2017.03
$ cat /etc/system-release
Amazon Linux AMI release 2017.03$ uname -a
Linux ip-10-64-65-42 4.9.43-17.38.amzn1.x86_64 #1 SMP Thu Aug 17 00:20:39 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Issue: Applying the default configuration for Headless Chromium with Puppeteer from the README manual doesn’t work.
Thrown error: 13 09 2017 09:07:50.677:ERROR [launcher]: Cannot start ChromiumHeadless /home/ec2-user/portals-frontend/frontend/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory
Karma config:
// ChromiumHeadless BROWSER
// https://github.com/karma-runner/karma-chrome-launcher#headless-chromium-with-puppeteer
const ChromiumRevision = require('puppeteer/package.json').puppeteer.chromium_revision;
const Downloader = require('puppeteer/utils/ChromiumDownloader');
const revisionInfo = Downloader.revisionInfo(Downloader.currentPlatform(), ChromiumRevision);
process.env.CHROMIUM_BIN = revisionInfo.executablePath;
// ...
karmaConfig = {
// Configuration for the ChromiumHeadless BROWSER
// https://github.com/GoogleChrome/puppeteer/issues/290#issuecomment-324448524
// https://github.com/karma-runner/karma-chrome-launcher/issues/73#issuecomment-247323225
customLaunchers: {
ChromiumHeadlessConfigured: {
base: 'ChromiumHeadless',
flags: ['--no-sandbox', '--disable-setuid-sandbox']
}
},
browsers: ['ChromiumHeadlessConfigured'],
/// ....
}
Tried options:
- running
$ sudo yum install libXss.so.1
gives:
No package libXss.so.1 available.
Error: Nothing to do
Reviewed and possibly related issues:
- https://github.com/GoogleChrome/puppeteer/issues/290
- https://github.com/karma-runner/karma-chrome-launcher/issues/73
- https://github.com/GoogleChrome/puppeteer/issues/391
- https://github.com/GoogleChrome/puppeteer/issues/560
- https://github.com/karma-runner/karma-chrome-launcher/issues/146
- https://github.com/atom/atom/issues/13176
Other tried solution, which didn’t work:
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 19
- Comments: 57 (3 by maintainers)
Just got chrome headless with puppeteer run successfully on Amazon Linux AMI 2017.09, and here’s the how-to: https://mockingbot.com/blog/run-puppeteer-chrome-headless-on-ec2-amazon-linux
We’ve updated the https://intoli.com/blog/installing-google-chrome-on-centos/ article to include to include a universal installer script for tracking down all of the missing Google Chrome dependencies from the CentOS 7 repos and installing them in
/opt/google/chrome/lib
. The linker will resolve them there when running the Google Chrome executable, but they won’t create potential conflicts with system packages (which can happen when installing the other RPMs directly). The tl;dr is that you can runand it will install the latest version of Google Chrome on both 6.X and 7.X variants of Amazon Linux, CentOS, and RHEL. You’ll want to take a look through the script before running it like that. What it’s doing is explained in detail here.
@sangaline: It works! You are fantastic! Thank you
Summary for others
react-snap
Step 1: Add the following steps to your
amplify.yml
config file to install ChromeStep 2: Add the following configuration to your
package.json
@mithung, if you run the script from https://intoli.com/blog/installing-google-chrome-on-centos/ , it will install all of the necessary dependencies in
/opt/google/chrome/lib/
. You can then set theLD_LIBRARY_PATH
environment variable before running your script so that the linker knows where to look.Are you able to install the
google-chrome-unstable
package? That should install all shared libs for you.yum install google-chrome-unstable
The solutions provided there don’t work anymore (ATK steps)
https://mockingbot.com/posts/run-puppeteer-chrome-headless-on-ec2-amazon-linux
here is update
curl https://intoli.com/install-google-chrome.sh | bash
it worked for me. my os is ami2 linux.@falco467 Thanks so much this works fine
@malyw We you able to run
google-chrome-stable
using Puppeteer?It appears that Puppeteer is unable to establish the WS connection and then times out. Do you have the same behavior?
However I am able to use
google-chrome-stable
to take screenshots through the CLI.I think that you probably need to specify the full executable path:
curl https://intoli.com/install-google-chrome.sh | bash
solves the problem for mehttps://medium.com/mockingbot/run-puppeteer-chrome-headless-on-ec2-amazon-linux-ami-6c9c6a17bee6
@yzhang After running below line sudo yum install cups-libs dbus-glib libXrandr libXcursor libXinerama cairo cairo-gobject pango
I could see that all dependencies are resolved
I am getting this error while running tests
Failed to launch chrome! /home/ec2-user/******/node_modules/puppeteer/.local-chromium/linux-508693/chrome-linux/chrome: symbol lookup error: /usr/lib64/libgtk-3.so.0: undefined symbol: g_type_add_instance_private
@awilson28
no
I didn’t receive message about it.
didn’t help me. (Linux ip-172-31-31-178 4.9.43-17.38.amzn1.x86_64 #1 SMP Thu Aug 17 00:20:39 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux)
Because CentOS/RHEL 6 isn’t supported by Chromium anymore. It hasn’t been for a good while.