File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,26 @@ protected function composerCommandInit(): void {
2828 }
2929
3030 $ this ->tester = new ApplicationTester ($ application );
31+
32+ // Composer autoload uses per-project Composer binary, if the
33+ // `composer/composer` is included in the project as a dependency.
34+ //
35+ // When the test runs and creates SUT, the Composer binary used is
36+ // from the SUT's `vendor` directory. The Customizer may remove the
37+ // `vendor/composer/composer` directory as a part of the cleanup, resulting
38+ // in the Composer autoloader having an empty path to the Composer binary.
39+ //
40+ // This is extremely difficult to debug, because there is no clear error
41+ // message apart from `Could not open input file`.
42+ //
43+ // To prevent this, we set the `COMPOSER_BINARY` environment variable to the
44+ // Composer binary path found in the system.
45+ // @see \Composer\EventDispatcher::doDispatch().
46+ $ composer_bin = shell_exec (escapeshellcmd ('which composer ' ));
47+ if ($ composer_bin === FALSE ) {
48+ throw new \RuntimeException ('Composer binary not found ' );
49+ }
50+ putenv ('COMPOSER_BINARY= ' . trim ((string ) $ composer_bin ));
3151 }
3252
3353 protected function assertComposerCommandSuccessOutputContains (string |array $ strings ): void {
You can’t perform that action at this time.
0 commit comments