Integration Tests Fail with Local PHP Binary in Paths Containing Spaces #38707
Labels
Area: Framework
Component: Integration
Issue: Confirmed
Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed
Priority: P2
A defect with this priority could have functionality issues which are not to expectations.
Progress: ready for dev
Reported on 2.4.7
Indicates original Magento version for the Issue report.
Reproduced on 2.4.x
The issue has been reproduced on latest 2.4-develop branch
Triage: Dev.Experience
Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Preconditions and environment
When attempting to run integration tests using a local PHP binary located in a path containing spaces, the command fails to execute and produces a "No such file or directory" error. The issue arises due to the lack of escaping for spaces in file paths, specifically when passthru() is used in \Magento\Developer\Console\Command\DevTestsRunCommand.
Preconditions:
Magento 2.4.7 installed.
Local PHP binary path includes spaces, e.g.,
/Users/MYUSER/Library/Application Support/myphp/bin/php81
.Running command
php bin/magento dev:tests:run integration
.Steps to reproduce
Ensure the local PHP binary path contains a space. You can check with
php -r "echo PHP_BINARY;"
Execute the command:
php bin/magento dev:tests:run integration
.Observe the failure in the command line output indicating "No such file or directory".
Expected result
The integration tests should run without errors, regardless of spaces in the PHP binary path.
Actual result
Additional information
Technical Details
The error occurs in
Magento\Developer\Console\Command\DevTestsRunCommand
, line 111:There is no prior validation or escaping of the command string to handle spaces in file paths.
Possible Solution
Replace
passthru()
with\Symfony\Component\Process\Process
to handle command execution. This component properly escapes command line arguments and can manage spaces in paths more reliably.Example of Problematic Usage
Additional Information
This issue only occurs when paths include spaces and using
passthru()
orexec()
for command execution. Utilizing\Symfony\Component\Process\Process
would mitigate this issue by providing more robust command line handling capabilities.Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: