question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Puppeter cannot start on CentOS 7

See original GitHub issue

Steps to reproduce

Environment:

  • Puppeteer version: Latest
  • Platform / OS version: CentOS 7
  • Node.js version: 8 or 10, it does not matter.

What steps will reproduce the problem?

Step 1: Install & run CentOS 7

$uname -a
Linux centos 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Step 2: install node, puppeteer and chromium missing dependencies

curl -sL https://rpm.nodesource.com/setup_8.x | sudo -E bash -
yum install nodejs

Install missing Chromium dependencies:

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

Step 3 - Create test.js

'use strict';
const puppeteer = require('puppeteer');
const fs = require('fs');
(async () => {
  console.info("Starting browser");
  let browser;
  try {
    browser = await puppeteer.launch({});
  } catch (e) {
    console.info("Unable to launch browser mode in sandbox mode. Lauching Chrome without sandbox.");
    browser = await puppeteer.launch({args:['--no-sandbox']});
  }
  console.info("Browser successfully started");
  console.info("Closing browser");
  await browser.close();
  console.info("Done");
})();

Step 4: Execute test.

$ node test.js

Starting browser
Unable to launch browser mode in sandbox mode. Lauching Chrome without sandbox.
Browser successfully started
Closing browser
Done

See that the browser cannot be launched without --no-sandbox

Analysis

Install “standard” Chromium on same linux box and see that Chromium can be successfully launched. Navigate to about:sandbox in “standard” Chromium and see that SUID sandboxing is used (because user namespace sandboxing is not available).

For SUID sandboxing to work, “standard” chromium uses a process called “chrome-sandbox”.

If you navigate to node_modules/puppeteer/.local-chromium/linux-549031, you notice that for puppeteer there is a file named chrome_sandbox (with an underscore).

Renaming this file to chrome-sandbox, making it owned by root and with attributes 4755 does the trick…

sudo mv chrome_sandbox chrome-sandbox
sudo chown root chrome-sandbox
sudo chmod 4755 chrome-sandbox

Now, run the test again

$ node test.js

Starting browser
Browser successfully started
Closing browser
Done

Alternatively, one can enable user namespaces in the kernel, but that’s not always possible, so I think Puppeteer should gracefully degrade the sandboxing as Google Chrome and Chromium do.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:19
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
zhoujingchaocommented, Jul 29, 2018

@apichery maybe you can try 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

const browser = await puppeteer.launch({ headless: true, args: [‘–no-sandbox’] })

11reactions
willemevenwelcommented, Nov 21, 2018

yum install pango libXcomposite libXcursor libXdamage libXext libXi libXtst cups-libs libXScrnSaver libXrandr GConf2 alsa-lib atk gtk3 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Setup Puppeteer In CentOS 7 - FrugalisMinds
Step 1:- Install Node JS In CentOS 7. curl -sL https://rpm.nodesource.com/setup_10.x | sudo -E bash - yum install nodejs · Step 2 :-...
Read more >
Failed to launch chrome using puppeteer in Centos 7
Puppeteer runs very well in my other Centos7 installations but don't understand why it isn't working here. Please HELP! Node v12.20.1 Puppeteer ......
Read more >
Puppeteer - npm
Puppeteer is a Node.js library which provides a high-level API to control Chrome/Chromium over the DevTools Protocol.
Read more >
setup puppeteer centos7 Code Example
... bash - yum install nodejs Step 2 :- Install Puppeteer In CentOS 7 npm i ... We are not able to launch...
Read more >
Troubleshooting - Puppeteer
Make sure all the necessary dependencies are installed. You can run ldd chrome | grep not on a Linux machine to check which...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found