Skip to content

Running simple-phpunit crashes due to autoload.php missing #31750

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

Closed
Inari-Whitebear opened this issue May 30, 2019 · 9 comments
Closed

Running simple-phpunit crashes due to autoload.php missing #31750

Inari-Whitebear opened this issue May 30, 2019 · 9 comments

Comments

@Inari-Whitebear
Copy link

Inari-Whitebear commented May 30, 2019

Symfony version(s) affected: 4.x, maybe more

Description
Trying get phpUnit to run I just get a crash:

PS E:\Dev\web\phpunit-test> ./vendor/bin/simple-phpunit
INFO: Could not find files for the given pattern(s).
Installing phpunit/phpunit (7.4.5)
Plugins have been disabled.
  - Installing phpunit/phpunit (7.4.5): Loading from cache
Created project in phpunit-7.4
composer.json has been updated
PHP Warning:  proc_open(): CreateProcess failed, error code - 2 in E:\Dev\Web\phpunit-test\vendor\symfony\phpunit-bridge\bin\simple-phpunit.php on line 131
PHP Warning:  proc_close() expects parameter 1 to be resource, bool given in E:\Dev\Web\phpunit-test\vendor\symfony\phpunit-bridge\bin\simple-phpunit.php on line 131
PHP Warning:  require(E:\Dev\Web\phpunit-test\vendor\bin\.phpunit\phpunit-7.4/vendor/autoload.php): failed to open stream: No such file or directory in E:\Dev\Web\phpunit-test\vendor\bin\.phpunit\phpunit-7.4\phpunit on line 4
PHP Fatal error:  require(): Failed opening required 'E:\Dev\Web\phpunit-test\vendor\bin\.phpunit\phpunit-7.4/vendor/autoload.php' (include_path='.;C:\php\pear') in E:\Dev\Web\phpunit-test\vendor\bin\.phpunit\phpunit-7.4\phpunit on line 4

It doesn't seem to actually run a "composer update" or something in E:\Dev\Web\phpunit-test\vendor\bin\.phpunit\phpunit-7.4/, so I have to do that myself.

How to reproduce
Create a new project from website skeleton. Install the phpunit bridge bundle as per https://symfony.com/doc/current/components/phpunit_bridge.html . Try to run ./vendor/bin/simple-phpunit

Might only happen in Windows/PowerShell or with some composer shell wrapper.

Possible Solution
cd to E:\Dev\Web\phpunit-test\vendor\bin\.phpunit\phpunit-7.4/ and do composer update

Additional context
Might only happen in Windows/PowerShell or with some composer shell wrapper.

@nicolas-grekas
Copy link
Member

I cannot reproduce but I didn't try on Windows/PowerShell, help wanted from someone that has the issue. Otherwise we'll have to close.

@misterx
Copy link
Contributor

misterx commented Jun 25, 2019

I have same error, on Windows 7, PHP 7.2.8
Steps to reproduce:

composer create-project symfony/skeleton testunit
cd testunit
composer require --dev symfony/phpunit-bridge
php bin\phpunit

Result:

INFO: Could not find files for the given pattern(s).
Installing phpunit/phpunit (6.5.14)
Plugins have been disabled.
  - Installing phpunit/phpunit (6.5.14): Loading from cache
Created project in phpunit-6.5
composer.json has been updated

Warning: proc_open(): CreateProcess failed, error code - 2 in E:\web\_hosts\test.local\symfony\testunit\vendor\symfony\phpunit-bridge\bin\simple-phpunit.php on line 131
Warning: proc_close() expects parameter 1 to be resource, boolean given in E:\web\_hosts\test.local\symfony\testunit\vendor\symfony\phpunit-bridge\bin\simple-phpunit.php on line 131
Warning: require(E:\web\_hosts\test.local\symfony\testunit\bin\.phpunit\phpunit-6.5/vendor/autoload.php): failed to open stream: No such file or directory in E:\web\_hosts\test.local\symfony\testunit\bin\.phpunit\phpunit-6.5\phpunit on line 4
Fatal error: require(): Failed opening required 'E:\web\_hosts\test.local\symfony\testunit\bin\.phpunit\phpunit-6.5/vendor/autoload.php' (include_path='.;C:\php\pear') in E:\web\_hosts\test.local\symfony\testunit\bin\.phpunit\phpunit-6.5\phpunit on line 4

@misterx
Copy link
Contributor

misterx commented Jun 25, 2019

Looks like problem in bypass_shell option in vendor\symfony\phpunit-bridge\bin\simple-phpunit.php on line 131. Composer runs from composer.bat file and located in some directory on my PC. That directory added into PATH env to execute composer anywhere, but proc_open with bypass_shell option don't know about this directory. When i set this option to false, phpunit-bridge working fine.

simple-phpunit use different exec ways, that probably a part of problem. Initially simple-phpunit trying to locate composer by backtick operator (that use cmd.exe and PATH env) on line 94 after that trying run composer by proc_open and bypassing cmd.exe env variables.

@Rebolon
Copy link

Rebolon commented Jun 26, 2019

Same problem on windows 10, PHP7.2
It almost works with a WSL (Windows Subsystem Linux)

@nicolas-grekas
Copy link
Member

@misterx thanks for the hints. Would you be able to submit a patch fixing the issue?

@fabpot fabpot closed this as completed Jul 3, 2019
fabpot added a commit that referenced this issue Jul 3, 2019
This PR was submitted for the 4.3 branch but it was merged into the 3.4 branch instead (closes #32187).

Discussion
----------

[PHPUnit] Fixed composer error on Windows

| Q             | A
| ------------- | ---
| Branch?       |  4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Fixed tickets | #31750
| License       | MIT

Fixes bug when composer runs  from bat file that described in PATH env.

Commits
-------

1f8927a Fixes windows error
@antsagithub
Copy link

Looks like problem in bypass_shell option in vendor\symfony\phpunit-bridge\bin\simple-phpunit.php on line 131. Composer runs from composer.bat file and located in some directory on my PC. That directory added into PATH env to execute composer anywhere, but proc_open with bypass_shell option don't know about this directory. When i set this option to false, phpunit-bridge working fine.

simple-phpunit use different exec ways, that probably a part of problem. Initially simple-phpunit trying to locate composer by backtick operator (that use cmd.exe and PATH env) on line 94 after that trying run composer by proc_open and bypassing cmd.exe env variables.

@zapo1234
Copy link

c'est chaud je cherche a faire des test unitaire via gitlab ci cd avec docker vendor/bin/phpunit ne se lance pas

@yanndeo
Copy link

yanndeo commented Feb 21, 2021

Hi zapo1234 , j'ai le même soucis impocis de jouer les test unitaire via gitlab ci cd avec docker. As tu trouvé une solution depuis lors svp?

@mfrosch
Copy link

mfrosch commented Feb 15, 2022

Error 404 - French not found ;)
I also get following on composer update:

In BinaryInstaller.php line 207:
                                                                                                                
  file_put_contents(/var/www/html/vendor/bin/simple-phpunit): failed to open stream: No such file or directory  

Is there some solution?

Cheers

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

Successfully merging a pull request may close this issue.