Search code examples
laravelgoogle-chromelaravel-dusk

Laravel Dusk running in Ubuntu 20.04 Error Chrome failed to start: exited abnormally


When I run

$ php artisan  dusk tests/Browser/ExampleTest.php

It prompt the error

  1. Tests\Browser\ExampleTest::testExample Facebook\WebDriver\Exception\UnknownServerException: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /snap/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5),platform=Linux 5.4.0-107-generic x86_64)

I check the chrome driver, it is install correctly.

$ php artisan dusk:chrome-driver

ChromeDriver binary successfully installed for version 100.0.4896.60.

Then I google the error. They said to check the chrome version

$ /usr/bin/chromium-browser --version

/usr/bin/chromium-browser: 12: xdg-settings: not found cannot create user data directory: /home/shiro/snap/chromium/1952: Permission denied

My goal is need to run Laravel Dusk in Ubuntu 20.04.


Solution

  • ***Make sure your chromium-browser need to REMOVE and INSTALL snap stable version MATCH with your Laravel Dusk Chrome Driver

    Below is the step, I run:-

    Next fix the Chromium issue by install via snap, then next error

    $ sudo snap refresh --edge chromium
    

    error: cannot communicate with server: Post http://localhost/v2/snaps/chromium: dial unix /run/snapd.socket: connect: no such file or directory

    to solve the error, need to update the packages.

    $ sudo add-apt-repository ppa:saiarcot895/chromium-beta
    $ sudo apt-get update
    $ sudo apt-get install chromium-browser
    

    Finally, it show the version. However, does not match my Laravel Chrome driver. Didn't solve my first issue. Still can't run dusk

    $ /usr/bin/chromium-browser --version
    Chromium 97.0.4692.20 Ubuntu 20.04
    

    Next install snap version of Chrome and remove the chromium-browser

    $ systemctl start snapd.service
    $ sudo snap install chromium
    $ sudo apt remove chromium-browser
    

    IMPORTANT NOTE

    $ /usr/bin/chromium-browser --version -bash: /usr/bin/chrome: No such file or directory

    Boom~ It works~