Home > Software engineering >  Google Chrome starts with multiple errors on WSL2 Ubuntu with Karma/Jasmine for Angular testing
Google Chrome starts with multiple errors on WSL2 Ubuntu with Karma/Jasmine for Angular testing

Time:03-18

In my Angular project I try to use Google Chrome for testing with Karma & Jasmine.

Basically everything works good, but when Google Chrome start it gives me multiple errors. I tried several tips from StackOverflow ansers in this topic, but nothing helped.

I use this versions:

  • Chrome 99.0.4844.51 (latest at this time)
  • Karma 6.3.16
  • Angular 13.2.3 (I think it's not relevant, but I don't know)

I use the ng test command for start.

I have this karma.conf.js file:

module.exports = function (config) {
  config.set({
    browserNoActivityTimeout: 500000,
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-coverage'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('@angular-devkit/build-angular/plugins/karma')
    ],
    client: {
      clearContext: false
    },
    coverageReporter: {
      dir: 'reports/coverage',
      reporters: [
        { type: 'html', subdir: 'report-html' },
        { type: 'lcov', subdir: 'report-lcov' }
      ],
      fixWebpackSourcePaths: true
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome', 'ChromeHeadless', 'ChromeHeadlessCI'],
    customLaunchers: {
        ChromeHeadlessCI: {
          base: 'ChromeHeadless',
          flags: ['--no-sandbox', '--disable-gpu']
        }
    },
    singleRun: false,
    restartOnFileChange: true
  });
};

I get this error message after ng test starts:

✔ Browser application bundle generation complete.
10 03 2022 16:13:58.251:WARN [karma]: No captured browser, open http://localhost:9876/
10 03 2022 16:13:58.258:INFO [karma-server]: Karma v6.3.16 server started at http://localhost:9876/
10 03 2022 16:13:58.259:INFO [launcher]: Launching browsers Chrome, ChromeHeadless, ChromeHeadlessCI with concurrency unlimited
10 03 2022 16:13:58.261:INFO [launcher]: Starting browser Chrome
10 03 2022 16:13:58.282:INFO [launcher]: Starting browser ChromeHeadless
10 03 2022 16:13:58.301:INFO [launcher]: Starting browser ChromeHeadless
10 03 2022 16:13:58.774:ERROR [launcher]: Cannot start ChromeHeadless
        [0310/161356.334:ERROR:sandbox_policy_base.cc(351)] Failed to add sandbox rule. error = 2, subsystem = 0, semantics = 0, pattern = '\tmp\karma-55099323\Default\chrome_debug.log'

DevTools listening on ws://127.0.0.1:9222/devtools/browser/e8db1b66-063b-4d55-8d9d-f17ab68c3c76
[0310/161356.340:ERROR:gpu_process_host.cc(966)] GPU process launch failed: error_code=2
[0310/161356.340:WARNING:gpu_process_host.cc(1277)] The GPU process has crashed 1 time(s)
[0310/161356.341:ERROR:sandbox_policy_base.cc(351)] Failed to add sandbox rule. error = 2, subsystem = 0, semantics = 0, pattern = '\tmp\karma-55099323\Default\chrome_debug.log'
[0310/161356.344:ERROR:simple_backend_impl.cc(80)] Failed to create directory: C:\Program Files\Google\Chrome\Application\99.0.4844.51\/tmp/karma-55099323\Default\Code Cache\js
[0310/161356.344:ERROR:simple_backend_impl.cc(80)] Failed to create directory: C:\Program Files\Google\Chrome\Application\99.0.4844.51\/tmp/karma-55099323\Default\Code Cache\wasm
[0310/161356.345:ERROR:simple_backend_impl.cc(80)] Failed to create directory: C:\Program Files\Google\Chrome\Application\99.0.4844.51\/tmp/karma-55099323\Default\Code Cache\js
[0310/161356.345:ERROR:simple_backend_impl.cc(80)] Failed to create directory: C:\Program Files\Google\Chrome\Application\99.0.4844.51\/tmp/karma-55099323\Default\Code Cache\wasm
[0310/161356.345:ERROR:simple_backend_impl.cc(735)] Simple Cache Backend: wrong file structure on disk: 1 path: C:\Program Files\Google\Chrome\Application\99.0.4844.51\/tmp/karma-55099323\Default\Code Cache\js
[0310/161356.345:ERROR:simple_backend_impl.cc(735)] Simple Cache Backend: wrong file structure on disk: 1 path: C:\Program Files\Google\Chrome\Application\99.0.4844.51\/tmp/karma-55099323\Default\Code Cache\wasm
[0310/161356.346:ERROR:simple_backend_impl.cc(80)] Failed to create directory: C:\Program Files\Google\Chrome\Application\99.0.4844.51\/tmp/karma-55099323\Default\Code Cache\js
[0310/161356.346:ERROR:simple_backend_impl.cc(80)] Failed to create directory: C:\Program Files\Google\Chrome\Application\99.0.4844.51\/tmp/karma-55099323\Default\Code Cache\wasm
[0310/161356.346:ERROR:sandbox_policy_base.cc(351)] Failed to add sandbox rule. error = 2, subsystem = 0, semantics = 0, pattern = '\tmp\karma-55099323\Default\chrome_debug.log'
[0310/161356.346:ERROR:simple_backend_impl.cc(80)] Failed to create directory: C:\Program Files\Google\Chrome\Application\99.0.4844.51\/tmp/karma-55099323\Default\Code Cache\js
[0310/161356.346:ERROR:simple_backend_impl.cc(735)] Simple Cache Backend: wrong file structure on disk: 1 path: C:\Program Files\Google\Chrome\Application\99.0.4844.51\/tmp/karma-55099323\Default\Code Cache\js
[0310/161356.346:ERROR:disk_cache.cc(185)] Unable to create cache
[0310/161356.346:ERROR:simple_backend_impl.cc(80)] Failed to create directory: C:\Program Files\Google\Chrome\Application\99.0.4844.51\/tmp/karma-55099323\Default\Code Cache\wasm
[0310/161356.346:ERROR:simple_backend_impl.cc(735)] Simple Cache Backend: wrong file structure on disk: 1 path: C:\Program Files\Google\Chrome\Application\99.0.4844.51\/tmp/karma-55099323\Default\Code Cache\wasm
[0310/161356.346:ERROR:disk_cache.cc(185)] Unable to create cache
[0310/161356.347:ERROR:gpu_process_host.cc(966)] GPU process launch failed: error_code=2
[0310/161356.347:WARNING:gpu_process_host.cc(1277)] The GPU process has crashed 2 time(s)
[0310/161356.347:ERROR:sandbox_policy_base.cc(351)] Failed to add sandbox rule. error = 2, subsystem = 0, semantics = 0, pattern = '\tmp\karma-55099323\Default\chrome_debug.log'
[0310/161356.348:ERROR:gpu_process_host.cc(966)] GPU process launch failed: error_code=2
[0310/161356.348:WARNING:gpu_process_host.cc(1277)] The GPU process has crashed 3 time(s)
[0310/161356.349:ERROR:disk_cache.cc(185)] Unable to create cache
[0310/161356.349:ERROR:sandbox_policy_base.cc(351)] Failed to add sandbox rule. error = 2, subsystem = 0, semantics = 0, pattern = '\tmp\karma-55099323\Default\chrome_debug.log'
[0310/161356.349:ERROR:shader_disk_cache.cc(612)] Shader Cache Creation failed: -2
[0310/161356.349:ERROR:gpu_process_host.cc(966)] GPU process launch failed: error_code=2
[0310/161356.349:WARNING:gpu_process_host.cc(1277)] The GPU process has crashed 4 time(s)
[0310/161356.350:ERROR:sandbox_policy_base.cc(351)] Failed to add sandbox rule. error = 2, subsystem = 0, semantics = 0, pattern = '\tmp\karma-55099323\Default\chrome_debug.log'
[0310/161356.350:ERROR:gpu_process_host.cc(966)] GPU process launch failed: error_code=2
[0310/161356.350:WARNING:gpu_process_host.cc(1277)] The GPU process has crashed 5 time(s)
[0310/161356.351:ERROR:sandbox_policy_base.cc(351)] Failed to add sandbox rule. error = 2, subsystem = 0, semantics = 0, pattern = '\tmp\karma-55099323\Default\chrome_debug.log'
[0310/161356.351:ERROR:gpu_process_host.cc(966)] GPU process launch failed: error_code=2
[0310/161356.351:WARNING:gpu_process_host.cc(1277)] The GPU process has crashed 6 time(s)
[0310/161356.351:FATAL:gpu_data_manager_impl_private.cc(447)] GPU process isn't usable. Goodbye.

10 03 2022 16:13:58.774:ERROR [launcher]: ChromeHeadless stdout:
10 03 2022 16:13:58.774:ERROR [launcher]: ChromeHeadless stderr: [0310/161356.334:ERROR:sandbox_policy_base.cc(351)] Failed to add sandbox rule. error = 2, subsystem = 0, semantics = 0, pattern = '\tmp\karma-55099323\Default\chrome_debug.log'

10 03 2022 16:13:59.662:ERROR [launcher]: ChromeHeadless stdout:
10 03 2022 16:13:59.662:ERROR [launcher]: ChromeHeadless stderr: [0310/161357.293:ERROR:sandbox_policy_base.cc(351)] Failed to add sandbox rule. error = 2, subsystem = 0, semantics = 0, pattern = '\tmp\karma-55099323\Default\chrome_debug.log'
[0310/161357.298:ERROR:gpu_process_host.cc(966)] GPU process launch failed: error_code=2
[0310/161357.298:WARNING:gpu_process_host.cc(1277)] The GPU process has crashed 1 time(s)
10 03 2022 16:13:59.663:ERROR [launcher]: ChromeHeadless failed 2 times (cannot start). Giving up.
10 03 2022 16:14:00.649:INFO [Chrome Headless 99.0.4844.51 (Windows 10)]: Connected on socket YtOU7-_7W0PbRVPmAAAF with id 17702890
10 03 2022 16:14:13.487:INFO [Chrome Headless 99.0.4844.51 (Windows 10)]: Connected on socket FeJO3V5aAFIEiQ6UAAAH with id 15106253
10 03 2022 16:14:16.710:INFO [Chrome Headless 99.0.4844.51 (Windows 10)]: Connected on socket qg_Q7YJ3LYwvL7uPAAAJ with id 33470413
10 03 2022 16:14:19.462:INFO [Chrome Headless 99.0.4844.51 (Windows 10)]: Connected on socket Y6vmb9CXiuS-76P2AAAL with id 52983855
10 03 2022 16:14:21.047:INFO [Chrome Headless 99.0.4844.51 (Windows 10)]: Connected on socket wJWd6lOjIWLW078vAAAN with id 86066564
10 03 2022 16:14:21.452:INFO [Chrome Headless 99.0.4844.51 (Windows 10)]: Connected on socket XdRruRvWXDbj8uzfAAAP with id 2895441
10 03 2022 16:14:23.313:INFO [Chrome Headless 99.0.4844.51 (Windows 10)]: Connected on socket 7rZRct4hVskmVUAkAAAR with id 86191305

Basically the Chrome starts, and works fine, but I want to disappear these error messages if it's possible.

Any idea how can I fix this?

CodePudding user response:

Based on @gftea's comments I found a solution.

In my WSL shell I run this command:

export TMPDIR="d:\\karma-temp"

After this the errors gone.

Then I put this export into my ~/.bashrc file to run it every time when Ubuntu starts.

  • Related