Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Geckodriver download issues on Mac #11

Merged
merged 2 commits into from
Mar 29, 2021
Merged

Conversation

derekmd
Copy link
Owner

@derekmd derekmd commented Mar 29, 2021

Fixes: #7 #8

The dusk:firefox-driver command is showing two issues on Mac:

  1. Fix Geckodriver download using Laravel Dusk 6.12.0+

    Laravel packages outside "laravel/framework" have a looser interpretation of semvar. [6.x] Add support for Mac ARM64 architecture laravel/dusk#876 changed the return values by public method Laravel\Dusk\OperatingSystem::id() when running in a Mac environment. It will now sometimes include the architecture in the string. That caused this package's dusk:firefox-driver command to skip the 'mac' operating system configuration.

    Remove the dependency on OperatingSystem::id() as Geckodriver doesn't (yet) have a distributed ARM binary.

  2. Fix the command on Mac failing to capture the extracted filename from the downloaded .tar.gz file. PHP's exec() doesn't populate its $output array argument when run:

    • within a Laravel Artisan command
    • within the PHPUnit test suite

    Appending 2>&1 to the command seems to cause the x geckodriver output string to be captured in $output so there are some stdout pipe shenanigans afoot. Linux terminals and Mingw-w64 on Windows don't have this behavior.

derekmd added 2 commits March 28, 2021 19:21
In v6.12.0 of package "laravel/dusk", it changed the
return values public method `Laravel\Dusk\OperatingSystem::id()`
when running in a Mac environment. It will now _sometimes_
include the architecture in the string.

This caused this package's `dusk:firefox-driver` command
to skip the operating system configuration.

Remove the dependency on `OperatingSystem::id()` as
Geckodriver doesn't (yet) have a distributed ARM binary.
When decompressing the Geckodriver .tar.gz to
the local filesystem, suppress stderr output to
the console. Instead capture it for delayed
output in the thrown RuntimeException.

This indirectly also seems to fix extracting
binaries on Mac and Windows (native). The string
"x geckodriver" is being printed to the Mac Terminal
& Windows Command Prompt when PHP's exec('tar -v...')
is called. But the $output array is empty despite
the tarball including a file and tar's verbose is on.

From (probably untrustworthy) php.net user posts, it
may be caused by a newline character being printed on
the terminal before the handled filename "x geckodriver"
is output.

Unrelated: call Laravel's ProcessUtils::escapeArgument()
instead of PHP standard library's escapeshellarg()
because apparently the latter has buggy edge cases.
@derekmd derekmd merged commit 956e222 into master Mar 29, 2021
@derekmd derekmd deleted the fix-mac-binary-handling branch March 29, 2021 00:45
derekmd added a commit that referenced this pull request Apr 14, 2021
So much for the comments in #11
as Geckodriver soon after added an ARM binary download. It still doesn't
offer an Intel-specific binary so Laravel Dusk's OperatingSystem::id()
method still requires a userland (packageland?) replacement to exclude
OS detection for 'mac-intel'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Geckodrivers Missing for Mac and Linux
1 participant