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 guessChromeBinaryPath on Ubuntu 24.04 #656

Open
wants to merge 1 commit into
base: 1.11
Choose a base branch
from

Conversation

divinity76
Copy link
Contributor

@divinity76 divinity76 commented Oct 25, 2024

This is a strange one:

  • On Ubuntu 24.04, shell_exec() does not have access to command
  • On Ubuntu 24.04, sh have access to command but it appears bugged, sh -c 'command -v bin1 bin2' will ignore bin2
  • To access a 'command -v' that actually check more than the first command, we need to use bash, not sh: bash -c 'command -v bin1 bin2 bin3' will look for all of them.

that sure is a headscratcher...

look at this:

$ command -v google-chrome chromium-browser chrome chromium
/usr/bin/chromium-browser
/snap/bin/chromium
$ php -r 'var_dump(shell_exec("command -v google-chrome chromium-browser chrome chromium"));'
NULL
$ php -r 'var_dump(shell_exec("sh -c '\''command -v google-chrome chromium-browser chrome chromium'\''"));'
NULL
$ php -r 'var_dump(shell_exec("sh -c '\''command -v chromium-browser google-chrome chromium-browser chrome chromium'\''"));'
string(26) "/usr/bin/chromium-browser
"
$ php -r 'var_dump(shell_exec("bash -c '\''command -v google-chrome chromium-browser chrome chromium'\''"));'
string(45) "/usr/bin/chromium-browser
/snap/bin/chromium
"

This is a strange one:
- On Ubuntu 24.04, shell_exec() does not have access to command
- On Ubuntu 24.04, sh have access to command but it appears bugged, sh -c 'command -v bin1 bin2' will ignore bin2
- To access a 'command -v' that actually check more than the first command, we need to use bash, not sh: bash -c 'command -v bin1 bin2 bin3' will look for all of them.

that sure is a headscratcher...

look at this:
$ command -v google-chrome chromium-browser chrome chromium
/usr/bin/chromium-browser
/snap/bin/chromium
$ php -r 'var_dump(shell_exec("command -v google-chrome chromium-browser chrome chromium"));'
NULL
$ php -r 'var_dump(shell_exec("sh -c '\''command -v google-chrome chromium-browser chrome chromium'\''"));'
NULL
$ php -r 'var_dump(shell_exec("sh -c '\''command -v chromium-browser google-chrome chromium-browser chrome chromium'\''"));'
string(26) "/usr/bin/chromium-browser
"
$ php -r 'var_dump(shell_exec("bash -c '\''command -v google-chrome chromium-browser chrome chromium'\''"));'
string(45) "/usr/bin/chromium-browser
/snap/bin/chromium
"
@enricodias
Copy link
Member

You are assuming that bash will be available, but it may not. 90% of the containers I worked with didn't have bash (which was super annoying, btw).

@divinity76
Copy link
Contributor Author

divinity76 commented Oct 29, 2024

Well then we can pick between checking a few common paths, or scanning PATH manually (eg #614 ) 🤔

@GrahamCampbell
Copy link
Member

GrahamCampbell commented Oct 29, 2024

I think it may be best to just specify the path using config or the CHROME_PATH env var.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants