Arjan Kempes
Arjan Kempes

Reputation: 27

Laravel + sail + dusk => Error: Could not start a new session [...] Chrome failed to start

I just can't get Laravel dusk running. I've searched the internet and tried almost everything. I hope anyone knows the trick.

To rule out any self introduced problems I stated with a brand new Laravel project: curl -s "https://laravel.build/example-app" | bash. I'm using a Macbook Air (M1 chip) and therefore I have to change the docker-compose.yml and add platform=linux/amd64 to the containers. Thereafter ran ./vendor/bin/sail build and started up the containers. Next installed Dusk: ./vendor/bin/sail composer require --dev laravel/dusk and ran the install command (./vendor/bin/sail artisan dusk:install) as by the documentation.

At this point no additional modifications in any file have been made. Laravel Dusk ships with the default browser test. (tests/Browser/ExampleTest.php) When I run the command ./vendor/bin/sail dusk the following error will show:

1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\SessionNotCreatedException: Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed.
  (chrome not reachable)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: '64671e354051', ip: '192.168.32.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.76-linuxkit', java.version: '11.0.13'
Driver info: driver.version: unknown
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: '64671e354051', ip: '192.168.32.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.76-linuxkit', java.version: '11.0.13'
Driver info: driver.version: unknown

/var/www/html/vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php:125
/var/www/html/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:372
/var/www/html/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:131
/var/www/html/tests/DuskTestCase.php:46
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:219
/var/www/html/vendor/laravel/framework/src/Illuminate/Support/helpers.php:243
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:220
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:98
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:66
/var/www/html/tests/Browser/ExampleTest.php:21

What I tried

./vendor/laravel/dusk/bin/chromedriver-linux: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

I Found an other StackOverflow post to fix this issue by installing the following packages via the sail root-shell: apt update; apt install libnss3-dev libgdk-pixbuf2.0-dev libgtk-3-dev libxss-dev;. Now the chromedriver-linux is starting without errors. Dusk still fails with the same error.

Has anyone a clue?

Upvotes: 1

Views: 1282

Answers (2)

Chris Banford
Chris Banford

Reputation: 83

After a long, tiring road of trying to get Sail/Docker working, have got to the point where Xdebug/VSCode and Unit Tests are working...

Next in line was 'dusk'

$ sail dusk

ERROR Command "dusk" is not defined.

All of the settings are as in: https://laravel.com/docs/10.x/sail#laravel-dusk

I really want to get everything working in Sail, before I commit to learning Laravel. Not much on Google for this issue.

Upvotes: 0

Citricguy
Citricguy

Reputation: 421

I was getting the same error when running sail artisan dusk.

When started using sail dusk instead everything worked.

Upvotes: 2

Related Questions