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.

Ubuntu: Cannot start ChromeHeadless

See original GitHub issue

I’m having some trouble getting ChromeHeadless to start. The error message doesn’t give much information:

22 03 2018 18:05:33.296:INFO [karma]: Karma v1.4.1 server started at http://0.0.0.0:9877/
22 03 2018 18:05:33.296:INFO [launcher]: Launching browser ChromeHeadless with unlimited concurrency
22 03 2018 18:05:33.320:INFO [launcher]: Starting browser ChromeHeadless
22 03 2018 18:05:33.404:ERROR [launcher]: Cannot start ChromeHeadless
	
22 03 2018 18:05:33.409:INFO [launcher]: Trying to start ChromeHeadless again (1/2).
22 03 2018 18:05:33.631:ERROR [launcher]: Cannot start ChromeHeadless
	
22 03 2018 18:05:33.634:INFO [launcher]: Trying to start ChromeHeadless again (2/2).
22 03 2018 18:05:34.008:ERROR [launcher]: Cannot start ChromeHeadless
	
22 03 2018 18:05:34.009:ERROR [launcher]: ChromeHeadless failed 2 times (cannot start). Giving up.

Here is my karma config:

process.env.CHROME_BIN = require('puppeteer').executablePath()  //for using ChromeHeadless

module.exports = function(config) {
    config.set({
        plugins: [
            require("karma-jasmine"),
            require("karma-typescript"),
            require("karma-chrome-launcher"),
            require('karma-jasmine-html-reporter'),
            require('karma-coverage-istanbul-reporter')
        ],
        frameworks: ["jasmine", "karma-typescript"],
        basePath: './',
        files: [
            'node_modules/es6-shim/es6-shim.js',
            'node_modules/babel-polyfill/dist/polyfill.js',
            'node_modules/reflect-metadata/Reflect.js',
            // zone.js
            'node_modules/zone.js/dist/zone.js',
            'node_modules/zone.js/dist/long-stack-trace-zone.js',
            'node_modules/zone.js/dist/proxy.js',
            'node_modules/zone.js/dist/sync-test.js',
            'node_modules/zone.js/dist/jasmine-patch.js',
            'node_modules/zone.js/dist/async-test.js',
            'node_modules/zone.js/dist/fake-async-test.js',
            'node_modules/resumablejs/resumable.js',
            'node_modules/hls.js/dist/hls.min.js',
            'src/assets/third-party/three.js',
            'src/assets/third-party/obj-loader.js',
            'src/assets/third-party/OrbitControls.js',
            'src/assets/third-party/THREEx.Fullscreen.js',
            { pattern: "src/app/**/*.html" },
            { pattern: "src/**/*.ts" }
        ],
        preprocessors: {
            "src/**/*.ts": ["karma-typescript"],
            "!node_modules": ["karma-typescript"]
        },
        client: {
            clearContext: false // leave Jasmine Spec Runner output visible in browser
        },
        reporters: ['progress', 'kjhtml', 'coverage-istanbul'],
        browsers: ["ChromeHeadless"],
        coverageIstanbulReporter: {
            reports: ['html', 'text-summary'],
            dir: 'coverage',
            skipFilesWithNoCoverage: false
        },
        karmaTypescriptConfig: {
            bundlerOptions: {
                entrypoints: /\.spec\.ts$/,
                transforms: [
                    require("karma-typescript-angular2-transform"),
                    require("karma-typescript-es6-transform")({ presets: ['es2015'] })
                ]
            },
            compilerOptions: {
                emitDecoratorMetadata: true,
                experimentalDecorators: true,
                module: "commonjs"
            },
            coverageOptions: {
                exclude: [
                    /\.(d|spec|test)\.ts$/i,
                    /main.ts$/i,
                    /polyfills.ts$/i,
                    /app.component.ts$/i,
                    /app.routes.ts$/i,
                    /module.ts$/i,
                    /Service.ts$/i
                ],
            },
            tsconfig: "./tsconfig.json"
        }
    });
};

Any suggestions?

I’m on Ubuntu 16.04 and Chrome 62.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

11reactions
shaunOclclcommented, May 31, 2018

@raveneyex I’ve defined a custom launcher based on ChromiumHeadless. The custom launcher allows flags to be passed to the Chrome (or Chromium) instance.

process.env.CHROMIUM_BIN = require('puppeteer').executablePath();
module.exports = function(config) {
  config.set({

   ....*other karma config settings*....

    browsers: ['HeadlessChromium'],
    customLaunchers: {
      HeadlessChromium: {
        base: 'ChromiumHeadless',
        flags: [
          '--no-sandbox',
          '--remote-debugging-port=9222',
          '--enable-logging',
          '--user-data-dir=./karma-chrome',
          '--v=1',
          '--disable-background-timer-throttling',
          '--disable-renderer-backgrounding',
          '--proxy-bypass-list=*',
          '--proxy-server=\'direct://\''
       ]
      }
    }
  });
};
1reaction
22shubham22commented, Nov 1, 2022

To make this run successfully, Please follow the procedure

Method 1: Most of the issues will be fixed and we can run ChromeHeadless if we download chromium version(debian) in wsl and install

step 1: install necessary packages

sudo apt-get update

sudo apt-get install -y curl unzip xvfb libxi6 libgconf-2-4

step 2: install chromium

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

sudo apt install ./google-chrome-stable_current_amd64.deb

If still problem persists, please follow the method 2

method 2: To run a basic Selenium UI test on any environment we need a browser and a driver to control the browser. So we’ve to make Windows’s Chrome browser and the chromedriver accessible from WSL.

step 1: Link Chrome browser on Windows

sudo ln -sf '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe' /usr/bin/google-chrome

step 2: Link chromedriver on Windows

sudo ln -s /mnt/c/Users/username/node_modules/chromedriver/lib/chromedriver/chromedriver.exe /usr/bin/chromedriver

step 3: Change CHROME_BIN (environmental variable’s default value)

export CHROME_BIN='/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'

If still problem persists, please follow the method 3

Method 3: This will help run puppetteer on Ubuntu, so let’s install necessary packages:

sudo apt-get 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

My StackOverflow solution link

for me it says, [INFO] [0518/130005.862638:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

I’ve done everything also provided different flags from issues but still couldn’t launch chrome headless on Ubuntu 22.04

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot start ChromeHeadless in Angular project using WSL ...
Method 3: This will help run puppetteer on Ubuntu, so let's install necessary packages: sudo apt-get install gconf-service libasound2 ...
Read more >
Building on Ubuntu - Cannot start ChromeHeadless
Hi all, I am building Sakai on ubuntu, and getting the following error: [INFO] 18 05 2021 12:26:49.803:INFO [launcher]: Starting browser ChromeHeadless
Read more >
Cannot start ChromeHeadless | Bitbucket Cloud - Jira
Since 27-02-2019 our Frontend UnitTests fail in Bitbucket pipeline with the following error: Testing GD.ProgramProcessing.WebUI... yarn run v1.12.3
Read more >
Troubleshooting - Puppeteer
Chromium currently does not provide arm64 binaries for Linux. There are only binaries. ... Chrome headless doesn't launch on Windows​.
Read more >
63. Install Puppeteer for adding Chrome Headless browser in ...
In this video we will see how to install Puppeteer for adding the chrome headless browser for ... Your browser can't play this...
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