Skip to content

Commit

Permalink
fix guessChromeBinaryPath on Ubuntu Linux + add Chromium
Browse files Browse the repository at this point in the history
on Ubutu Linux, "command" is a bash builtin, not a standalone binary, and shell_exec() tries to find the "command" binary and fails, thus the original code never worked on Ubuntu Linux
(I think the same is true for the entire Debian-derived family of operating systems, but don't quote me on that), 
fixing that by doing `bash -c 'command...`  instead.

Also added chromium support, for those who have Chromium but not Chrome installed.

It will look for Chrome first, and if it cannot find Chrome, it will look for Chromium second, and if all fails, it falls back to hardcoded "chrome".
  • Loading branch information
divinity76 authored Jan 11, 2024
1 parent 2b7cb13 commit 5b9dd36
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/AutoDiscover.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function guessChromeBinaryPath(): string
case 'Windows':
return self::getFromRegistry() ?? '%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe';
default:
return null === self::shellExec('command -v google-chrome') ? 'chrome' : 'google-chrome';
return explode("\n", (string)self::shellExec("bash -c 'command -v google-chrome chrome chromium chromium-browser'"), 2)[0] ?: 'chrome';
}
}

Expand Down

0 comments on commit 5b9dd36

Please sign in to comment.