Puppeteer: can't run puppeteer in centos7

Created on 19 Aug 2017  ·  78Comments  ·  Source: puppeteer/puppeteer

Server Info:
CUP: Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz
MemTotal: 1016396 kB
OS:CentOS Linux release 7.3.1611 (Core)
Node:v8.4.0

when I try to run my app in this server, there have an error throw:

(node:29208) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Failed to connect to chrome!

I want run Chromium which download by puppeteer manual,there have some log output:

robin@eve ~/project/memostickyserver/node_modules/puppeteer/.local-chromium/linux-494755/chrome-linux (master) $ chrome
robin@eve ~/project/memostickyserver/node_modules/puppeteer/.local-chromium/linux-494755/chrome-linux (master
) $ ./chrome
[28268:28268:0819/223159.486750:FATAL:zygote_host_impl_linux.cc(123)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.

0 0x7fd4bc6d6657 base::debug::StackTrace::StackTrace()

1 0x7fd4bc6ea311 logging::LogMessage::~LogMessage()

2 0x7fd4bb8db1f1 content::ZygoteHostImpl::Init()

3 0x7fd4bb575da0 content::BrowserMainLoop::EarlyInitialization()

4 0x7fd4bb57c4c3 content::BrowserMainRunnerImpl::Initialize()

5 0x7fd4bb575532 content::BrowserMain()

6 0x7fd4bc3e17fd content::ContentMainRunnerImpl::Run()

7 0x7fd4bc3e9314 service_manager::Main()

8 0x7fd4bc3e0462 content::ContentMain()

9 0x7fd4bb020b74 ChromeMain

10 0x7fd4b3da2b35 __libc_start_main

11 0x7fd4bb0209d0

Received signal 6

0 0x7fd4bc6d6657 base::debug::StackTrace::StackTrace()

1 0x7fd4bc6d61cf base::debug::(anonymous namespace)::StackDumpSignalHandler()

2 0x7fd4ba04d370

3 0x7fd4b3db61d7 __GI_raise

4 0x7fd4b3db78c8 __GI_abort

5 0x7fd4bc6d5202 base::debug::BreakDebugger()

6 0x7fd4bc6ea7cc logging::LogMessage::~LogMessage()

7 0x7fd4bb8db1f1 content::ZygoteHostImpl::Init()

8 0x7fd4bb575da0 content::BrowserMainLoop::EarlyInitialization()

9 0x7fd4bb57c4c3 content::BrowserMainRunnerImpl::Initialize()

10 0x7fd4bb575532 content::BrowserMain()

11 0x7fd4bc3e17fd content::ContentMainRunnerImpl::Run()

12 0x7fd4bc3e9314 service_manager::Main()

13 0x7fd4bc3e0462 content::ContentMain()

14 0x7fd4bb020b74 ChromeMain

15 0x7fd4b3da2b35 __libc_start_main

16 0x7fd4bb0209d0

r8: 00007fff21b42080 r9: 0000000000000395 r10: 0000000000000008 r11: 0000000000000206
r12: 00007fff21b424e0 r13: 000000000000016d r14: 00007fff21b424d8 r15: 00007fff21b424d0
di: 0000000000006e6c si: 0000000000006e6c bp: 00007fff21b42080 bx: 00007fff21b42080
dx: 0000000000000006 ax: 0000000000000000 cx: ffffffffffffffff sp: 00007fff21b41ed8
ip: 00007fd4b3db61d7 efl: 0000000000000206 cgf: 0000000000000033 erf: 0000000000000000
trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.
robin@eve ~/project/memostickyserver/node_modules/puppeteer/.local-chromium/linux-494755/chrome-linux (master*) $ ./chrome --no-sandbox
[0819/223234.158902:ERROR:nacl_helper_linux.cc(310)] NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly

pls help,how to fix this ?

host

Most helpful comment

@zhuyingda 's notes above will allow you to run puppeteer with --no-sandbox, but this is insecure as the sandbox is intended to isolate the process from the system.

The error message itself ('No usable sandbox!'), states If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox..

Running without a sandbox should be considered bad practice and potentially harmful.

Then again, if it works, it works.

In recap:
Install the deps by running:
yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc -y
... and in the source file, when you launch the browser itself specify:
const browser = await puppeteer.launch({ args: ['--no-sandbox']})

With that you'll be good to go (or should hopefully be), but it's playing a risky game, especially if this is a production system.

(Out of curiosity I checked, and thankfully; you can't run chrome --no-sandbox as root. ref. Running as root without --no-sandbox is not supported. See https://crbug.com/638180)

All 78 comments

No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.

Right in the error output. Did you go to the referenced page and read what it says about the problem and how to address it?

@Garbee Thanks to replay

yes,I read that page and try:

sudo chown root:root chrome_sandbox && sudo chmod 4755 chrome_sandbox && \
    export CHROME_DEVEL_SANDBOX="$PWD/chrome_sandbox"

get some other error:

DevTools listening on ws://127.0.0.1:45565/devtools/browser/8b502ff1-9ad6-40c7-a335-ec9221e1d914
[0820/113237.953713:ERROR:devtools_http_handler.cc(245)] Error writing DevTools active port to file
[0820/113237.923530:FATAL:platform_font_linux.cc(83)] Check failed: InitDefaultFont(). Could not find the default font

0 0x7f6fc457d657 base::debug::StackTrace::StackTrace()

1 0x7f6fc4591311 logging::LogMessage::~LogMessage()

2 0x7f6fc4aad472 gfx::PlatformFontLinux::PlatformFontLinux()

3 0x7f6fc4aae436 gfx::PlatformFont::CreateDefault()

4 0x7f6fc4aa68c9 gfx::Font::Font()

5 0x7f6fc3688004 content::RenderViewHostImpl::CreateRenderView()

6 0x7f6fc376c4b2 content::WebContentsImpl::CreateRenderViewForRenderManager()

7 0x7f6fc3531b5d content::RenderFrameHostManager::ReinitializeRenderFrame()

8 0x7f6fc3531247 content::RenderFrameHostManager::Navigate()

9 0x7f6fc3510e15 content::NavigatorImpl::NavigateToEntry()

10 0x7f6fc35117b5 content::NavigatorImpl::NavigateToPendingEntry()

11 0x7f6fc3501eb7 content::NavigationControllerImpl::NavigateToPendingEntryInternal()

12 0x7f6fc34fe0f2 content::NavigationControllerImpl::NavigateToPendingEntry()

13 0x7f6fc34fedc4 content::NavigationControllerImpl::LoadURLWithParams()

14 0x7f6fc6d293a8 headless::HeadlessWebContentsImpl::Create()

15 0x7f6fc6d2c134 headless::HeadlessBrowserContextImpl::CreateWebContents()

16 0x7f6fc428a40a headless::HeadlessShell::OnStart()

17 0x7f6fc6d2d862 headless::HeadlessBrowserImpl::RunOnStartCallback()

18 0x7f6fc7f807b1 headless::HeadlessContentMainDelegate::RunProcess()

19 0x7f6fc4287ec7 content::RunNamedProcessTypeMain()

20 0x7f6fc42887fd content::ContentMainRunnerImpl::Run()

21 0x7f6fc4290314 service_manager::Main()

22 0x7f6fc4287462 content::ContentMain()

23 0x7f6fc6d2e325 headless::(anonymous namespace)::RunContentMain()

24 0x7f6fc6d2e39c headless::HeadlessBrowserMain()

25 0x7f6fc428e0e2 headless::HeadlessShellMain()

26 0x7f6fc2ec7b6d ChromeMain

27 0x7f6fbbc49b35 __libc_start_main

28 0x7f6fc2ec79d0

Received signal 6

0 0x7f6fc457d657 base::debug::StackTrace::StackTrace()

1 0x7f6fc457d1cf base::debug::(anonymous namespace)::StackDumpSignalHandler()

2 0x7f6fc1ef4370

3 0x7f6fbbc5d1d7 __GI_raise

4 0x7f6fbbc5e8c8 __GI_abort

5 0x7f6fc457c202 base::debug::BreakDebugger()

6 0x7f6fc45917cc logging::LogMessage::~LogMessage()

7 0x7f6fc4aad472 gfx::PlatformFontLinux::PlatformFontLinux()

8 0x7f6fc4aae436 gfx::PlatformFont::CreateDefault()

9 0x7f6fc4aa68c9 gfx::Font::Font()

10 0x7f6fc3688004 content::RenderViewHostImpl::CreateRenderView()

11 0x7f6fc376c4b2 content::WebContentsImpl::CreateRenderViewForRenderManager()

12 0x7f6fc3531b5d content::RenderFrameHostManager::ReinitializeRenderFrame()

13 0x7f6fc3531247 content::RenderFrameHostManager::Navigate()

14 0x7f6fc3510e15 content::NavigatorImpl::NavigateToEntry()

15 0x7f6fc35117b5 content::NavigatorImpl::NavigateToPendingEntry()

16 0x7f6fc3501eb7 content::NavigationControllerImpl::NavigateToPendingEntryInternal()

17 0x7f6fc34fe0f2 content::NavigationControllerImpl::NavigateToPendingEntry()

18 0x7f6fc34fedc4 content::NavigationControllerImpl::LoadURLWithParams()

19 0x7f6fc6d293a8 headless::HeadlessWebContentsImpl::Create()

20 0x7f6fc6d2c134 headless::HeadlessBrowserContextImpl::CreateWebContents()

21 0x7f6fc428a40a headless::HeadlessShell::OnStart()

22 0x7f6fc6d2d862 headless::HeadlessBrowserImpl::RunOnStartCallback()

23 0x7f6fc7f807b1 headless::HeadlessContentMainDelegate::RunProcess()

24 0x7f6fc4287ec7 content::RunNamedProcessTypeMain()

25 0x7f6fc42887fd content::ContentMainRunnerImpl::Run()

26 0x7f6fc4290314 service_manager::Main()

27 0x7f6fc4287462 content::ContentMain()

28 0x7f6fc6d2e325 headless::(anonymous namespace)::RunContentMain()

29 0x7f6fc6d2e39c headless::HeadlessBrowserMain()

30 0x7f6fc428e0e2 headless::HeadlessShellMain()

31 0x7f6fc2ec7b6d ChromeMain

32 0x7f6fbbc49b35 __libc_start_main

33 0x7f6fc2ec79d0

r8: 00007ffd2a1a1030 r9: 0000000000000000 r10: 0000000000000008 r11: 0000000000000202
r12: 00007ffd2a1a1090 r13: 0000000000000076 r14: 00007ffd2a1a1088 r15: 00007ffd2a1a1080
di: 0000000000006e38 si: 0000000000006e38 bp: 00007ffd2a1a0c40 bx: 00007ffd2a1a0c40
dx: 0000000000000006 ax: 0000000000000000 cx: ffffffffffffffff sp: 00007ffd2a1a0a98
ip: 00007f6fbbc5d1d7 efl: 0000000000000202 cgf: 0000000000000033 erf: 0000000000000000
trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.
(node:28112) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: socket hang up
[0100/000000.311368:ERROR:broker_posix.cc(43)] Invalid node channel message

Check failed: InitDefaultFont(). Could not find the default font

@rlog Looks like a missing dependency. Are you sure you've installed all the dependencies listed here?

@paambaati I'm trying to install all this dependencies on centos 7, but nothing new install:

robin@eve ~ $ sudo yum install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 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 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
[sudo] password for robin:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
No package gconf-service available.
No package libasound2 available.
No package libatk1.0-0 available.
No package libc6 available.
No package libcairo2 available.
No package libcups2 available.
No package libdbus-1-3 available.
No package libexpat1 available.
No package libfontconfig1 available.
No package libgcc1 available.
No package libgconf-2-4 available.
No package libgdk-pixbuf2.0-0 available.
No package libglib2.0-0 available.
No package libgtk-3-0 available.
No package libnspr4 available.
No package libpango-1.0-0 available.
No package libpangocairo-1.0-0 available.
No package libstdc++6 available.
No package libx11-6 available.
No package libx11-xcb1 available.
No package libxcb1 available.
No package libxcomposite1 available.
No package libxcursor1 available.
No package libxdamage1 available.
No package libxext6 available.
No package libxfixes3 available.
No package libxi6 available.
No package libxrandr2 available.
No package libxrender1 available.
No package libxss1 available.
No package libxtst6 available.
Package ca-certificates-2017.2.14-70.1.el7_3.noarch already installed and latest version
No package fonts-liberation available.
No package libappindicator1 available.
No package libnss3 available.
No package lsb-release available.
Package xdg-utils-1.1.0-0.17.20120809git.el7.noarch already installed and latest version
Package wget-1.14-13.el7.x86_64 already installed and latest version
Nothing to do

You need to convert the package names to be RHEL names. Those are only the Debian names.

@Garbee I don't know how to convert, google them one by one ...?

That or grab an RPM copy of the installer and use software management tools to look at what the dependencies of the package are.

Having a similar issue. Here's what I discovered:

[root@li583-175 chrome-linux]# ldd chrome | more
linux-vdso.so.1 => (0x00007ffcd3ee4000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f55baf90000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f55bad8c000)
librt.so.1 => /lib64/librt.so.1 (0x00007f55bab83000)
libpangocairo-1.0.so.0 => not found
libpango-1.0.so.0 => not found
libcairo.so.2 => not found
libgobject-2.0.so.0 => /lib64/libgobject-2.0.so.0 (0x00007f55ba932000)
libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f55ba5fb000)
libX11.so.6 => /lib64/libX11.so.6 (0x00007f55ba2bc000)
libX11-xcb.so.1 => /lib64/libX11-xcb.so.1 (0x00007f55ba0ba000)
libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f55b9e98000)
libXcomposite.so.1 => not found
libXcursor.so.1 => not found
libXdamage.so.1 => not found
libXext.so.6 => not found
libXfixes.so.3 => not found
libXi.so.6 => not found
libXrender.so.1 => not found
libXtst.so.6 => not found
libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007f55b9c91000)
libnss3.so => /lib64/libnss3.so (0x00007f55b9966000)
libnssutil3.so => /lib64/libnssutil3.so (0x00007f55b9739000)
libsmime3.so => /lib64/libsmime3.so (0x00007f55b9512000)
libnspr4.so => /lib64/libnspr4.so (0x00007f55b92d3000)
libcups.so.2 => not found
libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f55b90a9000)
libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007f55b8e6b000)
libdbus-1.so.3 => /lib64/libdbus-1.so.3 (0x00007f55b8c23000)
libXss.so.1 => not found
libXrandr.so.2 => not found
libgconf-2.so.4 => not found
libgio-2.0.so.0 => /lib64/libgio-2.0.so.0 (0x00007f55b88a2000)
libasound.so.2 => /lib64/libasound.so.2 (0x00007f55b85a9000)
libm.so.6 => /lib64/libm.so.6 (0x00007f55b82a7000)
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
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f55b808f000)
libc.so.6 => /lib64/libc.so.6 (0x00007f55b7cce000)
/lib64/ld-linux-x86-64.so.2 (0x000055a8c8793000)
libffi.so.6 => /lib64/libffi.so.6 (0x00007f55b7ac6000)
libXau.so.6 => /lib64/libXau.so.6 (0x00007f55b78c1000)
libplc4.so => /lib64/libplc4.so (0x00007f55b76bc000)
libplds4.so => /lib64/libplds4.so (0x00007f55b74b8000)
libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007f55b7211000)
libz.so.1 => /lib64/libz.so.1 (0x00007f55b6ffb000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f55b6dd3000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f55b6bb9000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f55b6957000)

I had installed one of the missing packages manually, but it still doesn't find it. I can see that particular package under /usr/lib/libpangocairo-1.0.so.0.

So bottom of line , puppeteer can not work on centos !

Here's another issue I'm running into when trying on Docker Centos7:

[root@3dd3c09a9d40 opt]# npm install -g puppeteer

[email protected] install /usr/lib/node_modules/puppeteer
node install.js

Download failed: EACCES: permission denied, mkdir '/usr/lib/node_modules/puppeteer/.local-chromium'

I'm running as root. Not sure if that's the issue. I've changed ownership on that folder path. Even tried to create that folder manually and tried with sudo, yet I get that same error repeatedly.

@rlog try install fonts?

yum install ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc -y

Tried it in Ubuntu on Docker and got a similar message:

root@6c5ca63ee50a:/opt/node_modules/puppeteer/.local-chromium/linux-494755/chrome-linux# ./chrome
./chrome: error while loading shared libraries: libpangocairo-1.0.so.0: cannot open shared object file: No such file or directory

root@6c5ca63ee50a:/opt/node_modules/puppeteer/.local-chromium/linux-494755/chrome-linux# ldd ./chrome
linux-vdso.so.1 => (0x00007fffd9a6f000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f74809c4000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f74807c0000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f74805b8000)
libpangocairo-1.0.so.0 => not found
libpango-1.0.so.0 => not found
libcairo.so.2 => not found
libgobject-2.0.so.0 => not found
libglib-2.0.so.0 => not found
libX11.so.6 => not found
libX11-xcb.so.1 => not found
libxcb.so.1 => not found
libXcomposite.so.1 => not found
libXcursor.so.1 => not found
libXdamage.so.1 => not found
libXext.so.6 => not found
libXfixes.so.3 => not found
libXi.so.6 => not found
libXrender.so.1 => not found
libXtst.so.6 => not found
libgmodule-2.0.so.0 => not found
libnss3.so => not found
libnssutil3.so => not found
libsmime3.so => not found
libnspr4.so => not found
libcups.so.2 => not found
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f748038f000)
libfontconfig.so.1 => not found
libdbus-1.so.3 => not found
libXss.so.1 => not found
libXrandr.so.2 => not found
libgconf-2.so.4 => not found
libgio-2.0.so.0 => not found
libasound.so.2 => not found
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7480086000)
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
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f747fe70000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f747faa6000)
/lib64/ld-linux-x86-64.so.2 (0x00007f74887de000)
root@6c5ca63ee50a:/opt/node_modules/puppeteer/.local-chromium/linux-494755/chrome-linux#

I am using centos 6.9 , is there any step by step guide to install "puppeteer" on ?

node : v8.4.0
npm : 5.3.0
uname -a
Linux server 2.6.32-673.26.1.lve1.4.24.el6.x86_64 #1 SMP Wed Mar 29 17:09:57 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux

The best solution at this point is to use Ubuntu and follow these instructions https://github.com/GoogleChrome/puppeteer/issues/290#issuecomment-322921352.

I started development on OSX and didn't realize about this issue until we decided to go into production 😮.

@theoutlander Why install puppeteer globally in the first place? When installing globally and you're going into a non-user folder (as you are) you need to run as root. Hence why it is not recommended.

@Garbee you're right! I was running into other installation issues and overlooked that I was installing globally. (I recall seeing it, but was thinking I need to install it globally)

@Garbee kindly may you advice step by step for centos 6.X , i am very confused how to install ...

@historylife Upgrade to CentOS 7. 6 is no longer supported.

@Garbee i dont follow you , do you advise me to upgrade to CentOS 7. 6

@liulangyu90316 I have the same problem, centos7.3, I installed all the dependency but got socket hang up, and I can run ./chrome -v --no-sandbox --disable-setuid-sandbox but can not run puppeteer. After install your font dependency, everything got right. Thank you!

which OS is recommend? I can change my OS (except macOS and Windows)

@rlog you can take centos 7.3, same with me, and see this

@zhuyingda 's notes above will allow you to run puppeteer with --no-sandbox, but this is insecure as the sandbox is intended to isolate the process from the system.

The error message itself ('No usable sandbox!'), states If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox..

Running without a sandbox should be considered bad practice and potentially harmful.

Then again, if it works, it works.

In recap:
Install the deps by running:
yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc -y
... and in the source file, when you launch the browser itself specify:
const browser = await puppeteer.launch({ args: ['--no-sandbox']})

With that you'll be good to go (or should hopefully be), but it's playing a risky game, especially if this is a production system.

(Out of curiosity I checked, and thankfully; you can't run chrome --no-sandbox as root. ref. Running as root without --no-sandbox is not supported. See https://crbug.com/638180)

If you're a lunatic you can spend a few days trying to compile chromium from source, then compile the sandbox from source, and attempt to monkey-patch them together.
Build Chromium
Build Sandbox

Although if you look at the top of the Build Sandbox link, it appears they'll be dumping support for the SUID sandbox in favor User namespaces sandbox (sandbox list). Here's the thing, it looks like the chromium issue for replacing SUID has been open since 2013 so I wouldn't bank on that fixing this.

I have the same problem,too。

node:v8.4.0
centos:centos-release-7-2.1511.el7.centos.2.10.x86_64

(node:21521) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Failed to connect to chrome!
(node:21521) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@JustinYi922 You can try the font requirements which I mentioned

The sandbox is already in any local chromium download by puppeteer. Or just grab one out of https://download-chromium.appspot.com downloads. Once you setup the sandbox from one of these packages it will work with future builds. No need for manual compiling.

Thanks to all ! @zhuyingda 's solution fix this issue

env:

[localhost headless-chrome]$ cat /etc/release
CentOS Linux release 7.3.1611 (Core)
Derived from Red Hat Enterprise Linux 7.3 (Source)
cat: /etc/lsb-release.d: Is a directory
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

CentOS Linux release 7.3.1611 (Core)
CentOS Linux release 7.3.1611 (Core)
cpe:/o:centos:centos:7
[localhost headless-chrome]$ uname -a
Linux localhost.localdomain 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux



i got it works with below operations:

cd .local-chromium/linux-497674/chrome-linux
  sudo chown myID:myID *

  sudo chown root:root chrome_sandbox && sudo chmod 4755 chrome_sandbox && \
  export CHROME_DEVEL_SANDBOX="$PWD/chrome_sandbox"

  sudo chmod 644 locales/*

puppeteer can be launched without option: '--no-sandbox'

Centos 6.9

No package gtk3.x86_64 available

@DrLightman Centos 6 is no longer supported by the Chromium team. It hasn't been for years. You either need to upgrade your OS, dockerize things, or switch to a supported OS.

@DrLightman try the docker images. this or this

@Garbee @zhuyingda Thank you guys.

My solution is fix permissions on chrome_sandbox according to https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox.md#linux-sandbox
if --cap-add=CAP_NET_ADMIN for docker is ok for you

ENV CHROME_DEVEL_SANDBOX=~/node_modules/puppeteer/.local-chromium/linux-508693/chrome-linux/chrome_sandbox

RUN chown root $CHROME_DEVEL_SANDBOX
RUN chmod u+s,a+rx,g+rx $CHROME_DEVEL_SANDBOX

RUN chmod a+rx,g+rx ${CHROME_DEVEL_SANDBOX%/*}/chrome
RUN chmod u+r,a+r -R ${CHROME_DEVEL_SANDBOX%/*}

without capability you'll receive
Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted

Otherwise --no-sandbox is working solution

In case of installing missing dependencies on centos 7, I did the following.

  1. Check list of missing dependencies of chrome headless with ldd chrome | grep "not found"

It will get you something like this

libgtk-3.so.0 => not found
libgdk-3.so.0 => not found
  1. List a possible package to install that includes such dependencies via yum provides */libgtk-3.so.0

Output is like

Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * webtatic: us-east.repo.webtatic.com
gtk3-3.22.10-4.el7.i686 : The GIMP ToolKit (GTK+), a library for creating GUIs for X
Repo        : os
Matched from:
Filename    : /usr/lib/libgtk-3.so.0



gtk3-3.22.10-4.el7.x86_64 : The GIMP ToolKit (GTK+), a library for creating GUIs for X
Repo        : os
Matched from:
Filename    : /usr/lib64/libgtk-3.so.0
  1. Install a target package via yum install gtk3-3.22.10-4.el7.x86_64
  2. Now you're done. Try to list missing dependencies again, you will see that you just solved one more. So keep going.

Resolved without --no-sandbox

OS: CentOS Linux release 7.4.1708 (Core)
Kernel: 3.10.0-693.11.6.el7.x86_64

Dependencies

yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc

Download Chromium

Install separately as root permissions issue

cd /home/chromium
git clone https://github.com/scheib/chromium-latest-linux .
./update.sh

Sandbox Issue

https://github.com/GoogleChrome/puppeteer/issues/391#issuecomment-329137874
https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md

cd /home/chromium/latest
chown yourID:yourID *
# Need root permission
chown root:root chrome_sandbox && chmod 4755 chrome_sandbox
export CHROME_DEVEL_SANDBOX="/home/chromium/latest/chrome_sandbox"

Installation

export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
npm install --save puppeteer

PM2 Environment

{
  "env": {
    "NODE_ENV": "production",
    "CHROME_DEVEL_SANDBOX": "/home/chromium/latest/chrome_sandbox"
  }
}

Run

const browser = await puppeteer.launch({ executablePath: '/home/chromium/latest/chrome' });

Clear.

After trying install, I got this error:

node_modules/puppeteer/.local-chromium/linux-526987/chrome-linux/chrome: error while loading shared libraries: libatk-bridge-2.0.so.0: cannot open shared object file: No such file or directory

My OS System is CentOS6.4, has anybody got this error too?

Everything went well after switching to centos7... puppeteer required chromium, chromium required gtk3, and centos6 has only gtk2... DO NOT try to install puppeteer/chromium in CentOS6.. I've been struggled for one day...

@arganzheng I will not attempt to run puppeteer on low version centos any more, I think docker is the right way to run puppeteer and headless chrome if you can not update your system to centos7.
There has been a lot of ubantu headless chromium docker images in the docker hub, and I create a centos headless chromium docker image. Also, anyone can run this puppeteer crawler demo with my another docker image.

@arganzheng
要安装一些依赖才行

依赖库

yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 -y

字体

yum install ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc -y
可以去看下下面的这个网址
https://segmentfault.com/a/1190000011382062

I tried to install a lot of things, but still get a mistake.

/root/test/node_modules/[email protected]@puppeteer/.local-chromium/linux-526987/chrome-linux/chrome: error while loading shared libraries: libatk-bridge-2.0.so.0: cannot open shared object file: No such file or directory

CentOS release 6.4 (Final)

libatk-bridge-2.0.so.0 error centos 6.5

@lilijialiang @xiaojue
do you fix it in centos 6?
I install all CentOS Dependencies but it doesn't work
the same error

error while loading shared libraries: libatk-bridge-2.0.so.0: cannot open shared object file: No such file or directory

Hello,

Before I start, here is my server config:

 hardware: x86_64 (x86_64)
 os: CentOS Linux release 7.2.1511 (Core) running kernel 3.10.0-693.17.1.el7.x86_64
 memory: 5.52 GB
 cpu: 2x Intel(R) Xeon(R) CPU E5-2697A v4 @ 2.60GHz
 selinux enabled: false
 server type: vmware

I'm a newbie with Linux commands, but I still have libraries missing for chrome:

libXss.so.1 => not found
libatk-bridge-2.0.so.0 => not found
libgtk-3.so.0 => not found
libgdk-3.so.0 => not found

Those libraries are installed in my OS but are located in another directory.
I ran "ldd chrome" and except those 4, every library is located in /usr/lib64
The "not found" libraries are located in /usr/lib
I think that chrome is always looking for dependencies in /usr/lib64
As i don't have the writing permissions on those folders, I can't create a symlink of the requested libraries in /usr/lib64

Is it possible to change the path for these missing dependencies ?

Or maybe I'm totally wrong, I'm lost ^^

Thanks for your help !

@JustinYi922 I have the same question , it works but the picture is not all right , some charts can't be showed. so you resolve it now?

I'm getting another error when executing the node script (which runs puppeteer) through a PHP script.

(node:14405) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome!
[0424/163839.393626:ERROR:icu_util.cc(133)] Invalid file descriptor to ICU data received.
[0424/163839.393877:FATAL:content_main_delegate.cc(53)] Check failed: false. 
#0 0x55992b730b0c base::debug::StackTrace::StackTrace()
#1 0x55992b749780 logging::LogMessage::~LogMessage()
#2 0x559929ad2d23 content::ContentMainDelegate::TerminateForFatalInitializationError()
#3 0x55992b46bdeb content::ContentMainRunnerImpl::Initialize()
#4 0x55992b475b72 service_manager::Main()
#5 0x55992b46af14 content::ContentMain()
#6 0x55992f57a9b9 headless::(anonymous namespace)::RunContentMain()
#7 0x55992f57aa42 headless::HeadlessBrowserMain()
#8 0x55992b472f9d headless::HeadlessShellMain()
#9 0x559929ad11ac ChromeMain
#10 0x7f0b4d6f9c05 __libc_start_main
#11 0x559929ad102a _start

If I run the script with my user, it completes successfully. So maybe its a permission problem, but I can't figure out what is failing.

I managed to get Puppeteer taking screenshots without the --no-sandbox flag arg by setting a Linux kernel parameter to enable namespacing (on CentOS Linux release 7.4.1708).

As root user run:
echo "user.max_user_namespaces=15000" >> /etc/sysctl.conf
Check it worked with:
sudo sysctl -a | grep user.max_user_namespaces

Now reboot your system and run a script without using --no-sandbox e.g const browser = await puppeteer.launch();

If it still doesn't work you might be using an older Linux Kernel and will require a couple of extra args set in the Kernel.

As root user run:
grubby --args="user_namespace.enable=1 namespace.unpriv_enable=1" --update-kernel="$(grubby --default-kernel)"

Now reboot your system and check the Kernel command line for the 2 params you just added
cat /proc/cmdline

If they are in the command line run a script without using --no-sandbox again e.g const browser = await puppeteer.launch();

It should work now. If it doesn't you might be using an old kernel which doesn't support namespacing.

You can check your kernel version with:
uname -a
This is my kernel version which I've got Puppeteer running without --no-sandbox arg.
Linux centos7 3.10.0-693.21.1.el7.x86_64

Hope this helps :)

mark

mark

Anyone made it through with centos 6 - 6.9 ?

The following pkgs solved the issue for me on CentOS 7:

# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core)

# sudo ldd chrome | grep not
    libXtst.so.6 => not found
    libXss.so.1 => not found
    libatk-bridge-2.0.so.0 => not found
    libgtk-3.so.0 => not found
    libgdk-3.so.0 => not found

# yum install libXtst libXScrnSaver gtk3 -y

From a minimal CentOS 7 setup, I had to install the following packages to get it to work:

yum -y install libX11 libXcomposite libXcursor libXdamage libXext libXi libXtst cups-libs libXScrnSaver libXrandr alsa-lib pango atk at-spi2-atk gtk3 

@matrey Suggestion Worked for me. Thanks.

nanhaiyufu's solution helped me on Debian.

@JustinYi922 I have the same problem,and I have found that the reason is the system lacks the fonts,you should install the font,just like this.

@shellar1990 2017年提出这个问题的时候,我就知道是这个原因,只是我没有到git上同步一下这个状态。谢谢你哈。

libatk-bridge-2.0.so.0 error centos 6.5
centos 6.5 not support,you need centos7

mark

libatk-bridge-2.0.so.0 error centos 6.5
centos 6.5 not support,you need centos7

Really?
真的假的?

CentOS Dependencies
yum install -y pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc

What about atk-bridge?

I had also missing dependencies, so I installed chrome which did the trick for me.
I create a file called /etc/yum.repos.d/google-chrome.repo and added:

[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

then:

yum install google-chrome-stable

English:
If you have installed all the dependencies for centos,
But it is still not working!!!
Using Docker instead.

中文:
如果你全部的依赖都安装了,但是pptr依然无法运行,尝试使用Docker吧!
我在知乎写了一篇文章,也推荐给大家。
Linux下如何运行puppeteer? puppeteer搭配Docker光速部署的正确姿势

Tip:请不要害怕Docker,它非常简单好用方便安装。

建议:如果你的程序不是部署在产线环境,我非常建议你使用Docker来部署pptr开发的应用。而且大部分情况pptr开发的应用都是在dev环境运行的,无需部署到产线环境。

I have installed all the dependencies for centos, but it show , how to solve it?

./chrome --headless
./chrome: symbol lookup error: /usr/lib64/firefox/bundled/lib64/libcairo-gobject.so.2: undefined symbol: cairo_region_destroy

@matrey Worked for me in CentOS Linux release 7.5.1804 (Core) . Thanks. :)

我将这一句注释掉就可以了 // headless: false,
centos7正常打包

I tried the yum install of all the dependencies mentioned in the troubleshooting doc and in this forum, and atk and gtk3 are no longer available. I had to find them elsewhere using rpm, so making use of puppeteer in production systems seems to be difficult. Is there anyway to resolve dependencies through package.json npm, I do not want to make customers do major installs to use a reports system as I try to replace phantomjs.

Use docker

On Thu, Jul 25, 2019 at 12:10 AM steve-powers notifications@github.com
wrote:

I tried the yum install of all the dependencies mentioned in the
troubleshooting doc and in this forum, and atk and gtk3 are no longer
available. I had to find them elsewhere using rpm, so making use of
puppeteer in production systems seems to be difficult. Is there anyway to
resolve dependencies through package.json npm, I do not want to make
customers do major installs to use a reports system as I try to replace
phantomjs.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/GoogleChrome/puppeteer/issues/391?email_source=notifications&email_token=AABQXSZNG7NFKYRCWSFU4HTQBCEHJA5CNFSM4DXRNUR2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2W7YMY#issuecomment-514718771,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABQXS2G6A5WQJDM5RTA3G3QBCEHJANCNFSM4DXRNURQ
.

--
With Best Regards,
Constantine

Seems so convoluted. I hope you can get it working on CentOS 7. I managed to do it a month or so back. Actually had to switch servers and upgrade from CentOS 6 to run Puppeteer.

I have been trying to get non-docker centos7 puppeteer working and originally was running a big series of yum+rpm I found, which I complained about here. But combing through again I was able to use the solution last appended by jjejj on Mar 12, so edited this append.
Though cleaner with just yum, installing 21 libraries seems painful, if anyone figures out a LD_LIBRARY_PATH solution please append. I also appreciate the docker suggestion, I went down that path and did get things working well, but can't get the installer updated in time. Maybe next release :)

Try sudo yum install -y chromium then run npm I again and run your app.

Hope this helps for you , it resolved my issue.
Pupeteer Sandbox Issue resolved

@zhuyingda 's notes above will allow you to run puppeteer with --no-sandbox, but this is insecure as the sandbox is intended to isolate the process from the system.

The error message itself ('No usable sandbox!'), states If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox..

Running without a sandbox should be considered bad practice and potentially harmful.

Then again, if it works, it works.

In recap:
Install the deps by running:
yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc -y
... and in the source file, when you launch the browser itself specify:
const browser = await puppeteer.launch({ args: ['--no-sandbox']})

With that you'll be good to go (or should hopefully be), but it's playing a risky game, especially if this is a production system.

(Out of curiosity I checked, and thankfully; you can't run chrome --no-sandbox as root. ref. Running as root without --no-sandbox is not supported. See https://crbug.com/638180)

thanks !

Thanks @Sanjay007 !!

Hope this helps for you , it resolved my issue.
Pupeteer Sandbox Issue resolved

This solved my problem with the sandbox too!

#as root
cd /path-to/node_modules/puppeteer/.local-chromium/linux-XXXX/chrome-linux/
mv chrome_sandbox chrome-sandbox
chown root chrome-sandbox
chmod 4755 chrome-sandbox

Please update the docs on the sandbox for the current advise is not working at all in Centos7.

@

Thanks @Sanjay007 !!

Hope this helps for you , it resolved my issue.
Pupeteer Sandbox Issue resolved

This solved my problem with the sandbox too!

#as root
cd /path-to/node_modules/puppeteer/.local-chromium/linux-XXXX/chrome-linux/
mv chrome_sandbox chrome-sandbox
chown root chrome-sandbox
chmod 4755 chrome-sandbox

Please update the docs on the sandbox for the current advise is not working at all in Centos7.

Thanks god your fix work on my env, i'm on centos 7.8 using taiko

I have installed all the dependencies for centos, but it show , how to solve it?

./chrome --headless
./chrome: symbol lookup error: /usr/lib64/firefox/bundled/lib64/libcairo-gobject.so.2: undefined symbol: cairo_region_destroy

have you solved this problem? i faced this issue too

In our case (Amazon Linux 2) we fixed it by:

yum install -y alsa-lib.x86_64 \
atk.x86_64 \
cups-libs.x86_64 \
gtk3.x86_64 \
ipa-gothic-fonts \
libXcomposite.x86_64 \
libXcursor.x86_64 \
libXdamage.x86_64 \
libXext.x86_64 \
libXi.x86_64 \
libXrandr.x86_64 \
libXScrnSaver.x86_64 \
libXtst.x86_64 \
pango.x86_64 \
xorg-x11-fonts-100dpi \
xorg-x11-fonts-75dpi \
xorg-x11-fonts-cyrillic \
xorg-x11-fonts-misc \
xorg-x11-fonts-Type1 \
xorg-x11-utils
yum update nss -y

As explained in the docs: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix
We also scaled up to slightly more ram when it hung after doing the above.

Hope that helps someone.

On a barebones install of CentOS 7 (on Amazon AWS EC2), I was able to get chrome headless running with the following:
sudo yum install atk java-atk-wrapper at-spi2-atk gtk3 libXt

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aherriot picture aherriot  ·  172Comments

KJ1i picture KJ1i  ·  46Comments

lpellegr picture lpellegr  ·  63Comments

JaLe29 picture JaLe29  ·  58Comments

Nagisan picture Nagisan  ·  52Comments