Skip to content

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