Headless Chromium with Puppeteer doesn't work on Amazon Linux AMI
shospodarets opened this issue · comments
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:
- #290
- karma-runner/karma-chrome-launcher#73
- #391
- #560
- karma-runner/karma-chrome-launcher#146
- atom/atom#13176
Other tried solution, which didn't work:
Are you able to install the google-chrome-unstable
package? That should install all shared libs for you.
yum install google-chrome-unstable
sudo yum install libXss.so.1
This is trying to install the library file itself, not the containing package. The troubleshooting document has the list of CentOS packages that are required to be installed.
For libraries that aren't found you need to search your OSes packages for which one provides that file. Then install that package name.
Hey guys, thanks for the suggestions,
neither "sudo yum install google-chrome-unstable"
nor installing the dependencies from the troubleshooting document help for Amazon Linux AMI (Cent OS6).
On Cent OS7 sudo yum install google-chrome-stable
simply do the trick.
For Cent OS 6 only the custom build from https://intoli.com/blog/installing-google-chrome-on-centos/ helped:
sudo yum --nogpgcheck localinstall https://intoli.com/blog/installing-google-chrome-on-centos/google-chrome-stable-60.0.3112.113-1.x86_64.rpm
Works for me, so I'll close the issue.
@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.
google-chrome-stable --headless --disable-gpu --screenshot https://google.com
Same story here like @gregorym described - it is possible to get screenshots via CLI, but puppeteer can't connect to Chrome and times out.
@ebidel
sudo yum install google-chrome-unstable
gives "No package google-chrome-unstable available."
@Garbee
Thanks for pointing to the troubleshooting document, same as the previous, it doesn't help for Cent OS 6
@gregorym , @oaleynik
I couldn't use Chrome from Pupeter on Cent OS6, it just failed (sorry, didn't capture the console output.).
The prepared package installation from the article helped:
sudo yum --nogpgcheck localinstall https://intoli.com/blog/installing-google-chrome-on-centos/google-chrome-stable-60.0.3112.113-1.x86_64.rpm
@oaleynik Great news! I was able to run puppeteer on Amazon Linux using the custom compiled version of Chrome that @sambaiz did (#603 (comment)). 🏆
https://github.com/sambaiz/puppeteer-lambda-starter-kit/tree/master/chrome
ps: it logs a bunch of crap related to fonts:
[0919/051630.425386:WARNING:resource_bundle.cc(366)] locale_file_path.empty() for locale
[0919/051630.429873:WARNING:resource_bundle.cc(366)] locale_file_path.empty() for locale
DevTools listening on ws://127.0.0.1:41403/devtools/browser/fb3bc74b-bc01-4082-a3ca-3524a141a774
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 84: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 84: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 93: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 93: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 102: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 102: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Thanks for pointing to the troubleshooting document, same as the previous, it doesn't help for Cent OS 6
Because CentOS/RHEL 6 isn't supported by Chromium anymore. It hasn't been for a good while.
sudo yum --nogpgcheck localinstall https://intoli.com/blog/installing-google-chrome-on-centos/google-chrome-stable-60.0.3112.113-1.x86_64.rpm
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)
google-chrome-stable
/usr/bin/google-chrome-stable: symbol lookup error: /opt/google/chrome/lib/libgtk-3.so.0: undefined symbol: g_log_structured
@malyw I'm trying to install the intoli package on aws ec2 and am running into issues like cc @alexey-sh --- did you have to do anything else after running sudo yum --nogpgcheck localinstall https://intoli.com/blog/installing-google-chrome-on-centos/google-chrome-stable-60.0.3112.113-1.x86_64.rpm
? Were any other packages required?
did you have to do anything else after running
no
Were any other packages required?
I didn't receive message about it.
For the Amazon Linux AMI (Cent OS 6 AWS) the following worked without any additional packages/problems:
https://intoli.com/blog/installing-google-chrome-on-centos/
sudo yum --nogpgcheck localinstall https://intoli.com/blog/installing-google-chrome-on-centos/google-chrome-stable-60.0.3112.113-1.x86_64.rpm
For the Cent OS 7:
vim /etc/yum.repos.d/google-chrome.rep
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
# install the yum utilities
sudo yum install yum-utils
# download the google-chrome-stable package
yumdownloader google-chrome-stable
@alexey-sh apologies, I believe my last comment was unclear. I was addressing @malyw since he successfully installed the intoli package and cc'ing you because our predicaments were the same re: /usr/bin/google-chrome-stable: symbol lookup error: /opt/google/chrome/lib/libgtk-3.so.0: undefined symbol: g_log_structured
after downloading the package, I had to run sudo cp -a /opt/google/chrome/lib/. /usr/lib64/
. As a result, all of the packages that were previously missing (you can see the missing packages by running ldd /opt/google/chrome/chrome
; you'll also notice that they need to be in /usr/lib64/
) are no longer missing, though they are missing version information, which wasn't a problem for me.
If you run google-chrome-stable
you'll get the same error but if you're trying to run the chrome with selenium, you need only add 'headless', 'no-sandbox', 'window-size=1920x1080', '--disable-gpu' as config arguments.
Hope this helps!
tried the rpm out...
yum --nogpgcheck localinstall https://intoli.com/blog/installing-google-chrome-on-centos/google-chrome-stable-60.0.3112.113-1.x86_64.rpm
Loaded plugins: priorities, update-motd, upgrade-helper
google-chrome-stable-60.0.3112.113-1.x86_64.rpm | 87 MB 00:00:01
Examining /var/tmp/yum-root-D5OchW/google-chrome-stable-60.0.3112.113-1.x86_64.rpm: google-chrome-stable-60.0.3112.113-1.x86_64
Marking /var/tmp/yum-root-D5OchW/google-chrome-stable-60.0.3112.113-1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package google-chrome-stable.x86_64 0:60.0.3112.113-1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================
Installing:
google-chrome-stable x86_64 60.0.3112.113-1 /google-chrome-stable-60.0.3112.113-1.x86_64 245 M
Transaction Summary
================================================================================================================================
Install 1 Package
Total size: 245 M
Installed size: 245 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : google-chrome-stable-60.0.3112.113-1.x86_64 1/1
Verifying : google-chrome-stable-60.0.3112.113-1.x86_64 1/1
Installed:
google-chrome-stable.x86_64 0:60.0.3112.113-1
Complete!
[root@ip-10-55-11-89 ~]# ldd /opt/google/chrome/chrome | grep "not found"
libgconf-2.so.4 => not found
libXss.so.1 => not found
libatk-1.0.so.0 => not found
libgtk-3.so.0 => not found
libgdk-3.so.0 => not found
libgdk_pixbuf-2.0.so.0 => not found
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 run
# This installs Chrome on any RHEL/CentOS/Amazon Linux variant.
curl https://intoli.com/install-google-chrome.sh | bash
and 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.
I am getting below error while launching puppeteer in AWS EC2.
error while loading shared libraries: libdbus-glib-1.so.2: cannot open shared object file: No such file or directory
I see that below dependencies are not installed.
$ ldd chrome | grep not
libdbus-glib-1.so.2 => not found
libcairo-gobject.so.2 => not found
libcairo-gobject.so.2 => not found
libXinerama.so.1 => not found
@mithung, which AMI and installation method are you using?
I am using Amazon Linux AMI to create instance.
Puppeteer is one of dependencies in my "package.json". When I do "npm install". I could see that chromium is downloaded.
When I run my puppeteer some dependencies like "libXss.so.1" were missing, I have gone through
https://mockingbot.com/posts/run-puppeteer-chrome-headless-on-ec2-amazon-linux
and installed them.
Now, when I run my Puppeteer test, I am getting below error.
Failed to launch chrome!
*****node_modules/puppeteer/.local-chromium/linux-508693/chrome-linux/chrome:while loading shared libraries: libdbus-glib-1.so.2: cannot open shared object file: No such file or directory
@mithung can you check if you installed dbus-glib? did you forget to run below line?
$ sudo yum install cups-libs dbus-glib libXrandr libXcursor libXinerama cairo cairo-gobject pango
@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
@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 the LD_LIBRARY_PATH
environment variable before running your script so that the linker knows where to look.
# Run this once to install Google Chrome.
curl https://intoli.com/install-google-chrome.sh | bash
# Invoke your script with `LD_LIBRARY_PATH` set.
LD_LIBRARY_PATH=/opt/google/chrome/lib/:${LD_LIBRARY_PATH} node your-script.js
@yzhang solution worked for me. If you want to do this while deploying. You can put his blog (contents - the rhetoric) into a bash file and have it run after npm install
#!/bin/bash
cd node_modules/puppeteer/
cd .local-chromium/linux-*/chrome-linux
sudo yum install cups-libs dbus-glib libXrandr libXcursor libXinerama cairo cairo-gobject pango
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/atk-2.22.0-3.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-atk-2.22.0-2.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-core-2.22.0-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/g/GConf2-3.2.6-7.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libXScrnSaver-1.2.2-6.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libxkbcommon-0.3.1-1.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libwayland-client-1.2.0-3.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libwayland-cursor-1.2.0-3.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/g/gtk3-3.10.4-1.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/16/Fedora/x86_64/os/Packages/gdk-pixbuf2-2.24.0-1.fc16.x86_64.rpm
@sangaline thanks for the update!
I installed the script using curl https://intoli.com/install-google-chrome.sh | bash
as per the comment
It finished with the number of errors, but the success message in the very end:
27647 blocks
rm: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
awk: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
Finding dependency for
arch: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
/usr/bin/python: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
arch: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time referencearch: relocation error
: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
sed: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
sed: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
wget: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
cpio: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
rpm2cpio: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
rm: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
find: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
grep: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
xargs: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
rm: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
awk: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
Finding dependency for
arch: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
arch: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
sed: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
arch: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
/usr/bin/python: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
sed: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
wget: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
cpio: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
rpm2cpio: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
rm: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
find: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
grep: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
xargs: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
rm: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
grep: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
rm: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
Successfully installed google-chrome-stable-63.0.3239.132-1.x86_64.rpm
When I try running the Chrome, the error comes back:
google-chrome-stable --version
/bin/bash: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
or:
google-chrome-stable --headless --disable-gpu --screenshot https://intoli.com/blog/installing-google-chrome-on-centos/
/bin/bash: relocation error: /opt/google/chrome/lib/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
Here is the instance info:
$ cat /etc/system-release
CentOS release 6.9 (Final)
$ uname -a
Linux phantomjsbuild2 2.6.32-358.6.2.el6.x86_64 #1 SMP Thu May 16 20:59:36 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Any thoughts/suggestions are appreciated.
@malyw, thanks for reporting that. Unfortunately, it seems that the glibc version on the 6.9 release is incompatible with the packages being grabbed from CentOS 7. I've updated the script to abort when it's running on 6.9 variants and to print out more accurate/informative messages about the success outcome. I'm working on a fix for this, but it's going to be more complicated than simply relocating the libraries.
@sangaline just checked:
Thanks for updating.
Please let us know if you have a fix.
@malyw, I have an experimental fix up now that works for me when I test it on RHEL 6.9. Let me know if you run into any issues with it and I'll take another look.
Note that this fix is not compatible with using LD_LIBRARY_PATH=/opt/google/chrome/lib/:${LD_LIBRARY_PATH} node your-script.js
to launch Puppeteer, you'll need to specify the executable that Puppeteer uses to be the one in /opt/google/chrome/
.
@sangaline Tested and it works perfectly. Many thanks!
@malyw
hi, could you please help me on how we're you able to run the puppeteer? im on RHEL 6.9 and installed @sangaline script. I also set the executablePath to /opt/google/chrome/chrome but receiving
"(node:63194) UnhandledPromiseRejectionWarning: Error: socket hang up". thank you very much.
@deedc I have applied the updated solution accordingly to #765 (comment) and it just worked.
But in the end, I switched to CentOS 7 to be able easily to use OOB google-chrome.
curl https://intoli.com/install-google-chrome.sh | bash
solves the problem for me
@sangaline finally made it work after lot of attempts. Thanks a lot.
Hi,
I use the new AWS Amplify console for CI/CD. I need to run puppeteer in my react application build for SEO/SMO optimization purpose (react-snap). Despite the fact that in runs fine on my local machine, I am unable to achieve that goal on my CI/CD setup.
AWS amplify provisions a build environment with a Docker image FROM amazonlinux:1. The content of the Dockerfile and the amplify build script are attached for your information (see attached dockerfile.txt and amplify.yml.txt).
When I simply run my basic build, I receive the following error when react snap tries to trigger chrome (see attached log_basic_setup.txt for full logs)
Error: Failed to launch chrome!
/codebuild/output/src892377177/src/app.weighers.club/node_modules/puppeteer/.local-chromium/linux-609904/chrome-linux/chrome: error while loading shared libraries: libXcomposite.so.1: cannot open shared object file: No such file or directory
When I try to fix that error by installing chrome with curl https://intoli.com/install-google-chrome.sh | bash
, the build stays stucked indefinitely on the following operation (see attached log_install_chrome.txt for full logs)
2018-12-06T19:26:54.596Z [INFO]: Finding dependency for libwayland-egl.so.1
Any advice and help you may provide is welcome !
@jpbourgeon Are you still getting that error? We updated the script yesterday and it should have resolved the Wayland dependency issue.
My last test was yesterday at 20:00 ; I guess we are not on the same Time Zone :)
I just tried and the script works now. Chrome is successfully installed
Now that chrome is installed, how should I use it ? I have the following configuration
'reactSnap': {
'puppeteerArgs': ['--no-sandbox', '--disable-setuid-sandbox'],
'puppeteerExecutablePath': '/opt/google/chrome/'
}
But the generations throws without an explicit error message. Any advice on how I should proceed next ?
I think that you probably need to specify the full executable path:
'reactSnap': {
'puppeteerArgs': ['--no-sandbox', '--disable-setuid-sandbox'],
'puppeteerExecutablePath': '/opt/google/chrome/google-chrome'
}
@sangaline: It works! You are fantastic! Thank you
Summary for others
- Platform: AWS Amplify continuous deployment
- OS: Amazon Linux Docker image
- Purpose: Use puppeteer on CI/CD to prerender a React app with
react-snap
Step 1: Add the following steps to your amplify.yml
config file to install Chrome
frontend:
phases:
preBuild:
commands:
- '# This installs Chrome on any RHEL/CentOS/Amazon Linux variant.'
- curl https://intoli.com/install-google-chrome.sh | bash
Step 2: Add the following configuration to your package.json
'reactSnap': {
'puppeteerArgs': ['--no-sandbox', '--disable-setuid-sandbox'],
'puppeteerExecutablePath': '/opt/google/chrome/google-chrome'
}
Hi @sangaline
Now that it works fine, I would like to optimize my build time on AWS by caching the installed chrome package and it's dependencies.
Downloading and installing Chrome doubles my build time :-)
What paths should I cache ? Where are the downloaded/installed dependencies stored ? Is it enough to cache '/opt/google/**/*'
}
Best regards!
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
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/atk-2.28.1-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-atk-2.26.2-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-core-2.28.0-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/g/GConf2-3.2.6-7.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libXScrnSaver-1.2.2-6.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libxkbcommon-0.3.1-1.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libwayland-client-1.2.0-3.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libwayland-cursor-1.2.0-3.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/g/gtk3-3.10.4-1.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/16/Fedora/x86_64/os/Packages/gdk-pixbuf2-2.24.0-1.fc16.x86_64.rpm
Hi,
I use AWS Amplify Console with Amazon Linux AMI release 2018.03 with an Angular 7 app.
Google-chrome-stable and Puppeteer are installed but it still fails...
//////////////////////////////////////////////////////////////////////////////
Cannot start ChromeHeadless
/puppeteer/.local-chromium/linux-624487/chrome-linux/chrome: error while loading shared libraries: libcairo-gobject.so.2: cannot open shared object file: No such file or directory
curl https://intoli.com/install-google-chrome.sh | bash
it worked for me. my os is ami2 linux.
curl https://intoli.com/install-google-chrome.sh | bash
also worked for me on Amazon Linux 2 AMI (though it failed on Amazon Linux AMI 2018.03.0)
I use AWS Amplify Console now.
I had some major issues getting this working on the 2018.03 version of amazon linux but managed it getting to work after a while.
My version
NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
Amazon Linux AMI release 2018.03
Some issues may or may not be solved when i locked the puppeteer version to 2.0.0. In addition the the below ones i had to run
sudo yum install -y cups-libs dbus-glib libXrandr libXcursor libXinerama cairo cairo-gobject pango
sudo chown -R 496:494 "/tmp/.npm"
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
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/atk-2.28.1-1.el7.x86_64.rpm sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-atk-2.26.2-1.el7.x86_64.rpm sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-core-2.28.0-1.el7.x86_64.rpm sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/g/GConf2-3.2.6-7.fc20.x86_64.rpm sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libXScrnSaver-1.2.2-6.fc20.x86_64.rpm sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libxkbcommon-0.3.1-1.fc20.x86_64.rpm sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libwayland-client-1.2.0-3.fc20.x86_64.rpm sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libwayland-cursor-1.2.0-3.fc20.x86_64.rpm sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/g/gtk3-3.10.4-1.fc20.x86_64.rpm sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/16/Fedora/x86_64/os/Packages/gdk-pixbuf2-2.24.0-1.fc16.x86_64.rpm
I put everything in a post deploy script in .ebextensions and not it works as it should
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/install_dependencies.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
cd /var/app/current
sudo yum install -y cups-libs dbus-glib libXrandr libXcursor libXinerama cairo cairo-gobject pango
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/atk-2.28.1-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-atk-2.26.2-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-core-2.28.0-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/g/GConf2-3.2.6-7.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libXScrnSaver-1.2.2-6.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libxkbcommon-0.3.1-1.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libwayland-client-1.2.0-3.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/l/libwayland-cursor-1.2.0-3.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/20/Fedora/x86_64/os/Packages/g/gtk3-3.10.4-1.fc20.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/16/Fedora/x86_64/os/Packages/gdk-pixbuf2-2.24.0-1.fc16.x86_64.rpm
sudo rpm -ivh --nodeps http://dl.fedoraproject.org/pub/archive/fedora/linux/releases/16/Fedora/x86_64/os/Packages/gdk-pixbuf2-2.24.0-1.fc16.x86_64.rpm
sudo chown -R 496:494 "/tmp/.npm"
Those fixed all missed dependencies:
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/atk-2.28.1-2.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-atk-2.26.2-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-core-2.28.0-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/8/AppStream/x86_64/os/Packages/libXScrnSaver-1.2.3-1.el8.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/gtk3-3.22.30-5.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/gdk-pixbuf2-2.36.12-3.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/libwayland-client-1.15.0-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/libepoxy-1.5.2-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/libxkbcommon-0.7.1-3.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/libwayland-cursor-1.15.0-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/libwayland-egl-1.15.0-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/libpng-1.5.13-7.el7_2.x86_64.rpm
But when I try to install the last one: libpng, I got an error that tells libpng-1.5.13-7.el7_2.x86_64 conflicts with libpng-2:1.2.49-2.14.amzn1.x86_64
Any idea how can I avoid that?
I am using Amazon Linux AMI to create instance.
Puppeteer is one of dependencies in my "package.json". When I do "npm install". I could see that chromium is downloaded.
When I run my puppeteer some dependencies like "libXss.so.1" were missing, I have gone through
https://mockingbot.com/posts/run-puppeteer-chrome-headless-on-ec2-amazon-linux
and installed them.Now, when I run my Puppeteer test, I am getting below error.
Failed to launch chrome! *****node_modules/puppeteer/.local-chromium/linux-508693/chrome-linux/chrome:while loading shared libraries: libdbus-glib-1.so.2: cannot open shared object file: No such file or directory
did you find any solution?
@sangaline: It works! You are fantastic! Thank you
Summary for others
- Platform: AWS Amplify continuous deployment
- OS: Amazon Linux Docker image
- Purpose: Use puppeteer on CI/CD to prerender a React app with
react-snap
Step 1: Add the following steps to your
amplify.yml
config file to install Chromefrontend: phases: preBuild: commands: - '# This installs Chrome on any RHEL/CentOS/Amazon Linux variant.' - curl https://intoli.com/install-google-chrome.sh | bash
Step 2: Add the following configuration to your
package.json
'reactSnap': { 'puppeteerArgs': ['--no-sandbox', '--disable-setuid-sandbox'], 'puppeteerExecutablePath': '/opt/google/chrome/google-chrome' }
Hi had a quick question: if you don't have an amplify.yml where are you suppose to tell amplify to install chrome?? all amplify gave me was an aws-exports.js and an amplify folder with all my backend. I think I need to be connected to a git repo and have continuous deployments set up, but I don't so can I just make my own amplify.yml? will that break the project? will amplify even recognize the file?
I was able to install and run puppeteer correctly installing this
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
sudo yum install ./google-chrome-stable_current_*.rpm
I was able to install and run puppeteer correctly installing this wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm sudo yum install ./google-chrome-stable_current_*.rpm
This worked for me too.
Thanks @slaniado
Currently you can also use the google-chrome-stable package directly:
sudo yum install google-chrome-stable
Hi, my build fails after i was successfully able to crawl the site. Does anyone know how to fix it?
Here's my amplify.yml
version: 1
frontend:
phases:
preBuild:
commands:
- cd client
- curl https://intoli.com/install-google-chrome.sh | bash
- npm ci --force
build:
commands:
- npm run build
artifacts:
baseDirectory: client/build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Currently you can also use the google-chrome-stable package directly: sudo yum install google-chrome-stable
I tried running
packages:
yum:
google-chrome-stable: []
but i keep getting Yum does not have google-chrome-stable available for installation
Ran into numerous issues trying to install and run pyppeteer on amazon linux container, the following ended up working for me
sudo amazon-linux-extras install epel -y
yum install -y chromium
yum install -y xorg-x11-server-Xvfb gtk3-devel libnotify-devel nss libXScrnSaver alsa-lib
Ran into numerous issues trying to install and run pyppeteer on amazon linux container, the following ended up working for me
sudo amazon-linux-extras install epel -y yum install -y chromium yum install -y xorg-x11-server-Xvfb gtk3-devel libnotify-devel nss libXScrnSaver alsa-lib
Thanks @Tamupiwa for the response, I am doing this on elastic beanstalk which config file do you add this code.
@SmtOmega
This is what I use in Elastic Beanstalk:
File: ´.ebextensions/packages.config´
commands:
install-chrome:
command: |
google-chrome --version || { wget -O google-chrome-stable.rpm https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm && sudo yum -y install ./google-chrome-stable.rpm; }
@SmtOmega This is what I use in Elastic Beanstalk:
File: ´.ebextensions/packages.config´
commands: install-chrome: command: | google-chrome --version || { wget -O google-chrome-stable.rpm https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm && sudo yum -y install ./google-chrome-stable.rpm; }
@falco467 Thanks so much this works fine