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
- The files in
./vendor/laravel/dusk/bin/
have the right permissions. ./vendor/bin/sail artisan dusk:chrome-driver --all
=>ChromeDriver binary successfully installed for version 100.0.4896.60.
. But the same dusk error will show.- Tried to run the ChromeDriver directly:
./vendor/bin/sail bash
=>./vendor/laravel/dusk/bin/chromedriver-linux
. This results in an error:
./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?