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

[WebServerBundle] server not work after update #25515

Closed
russoalberto opened this issue Dec 15, 2017 · 33 comments

Comments

Projects
None yet
@russoalberto
Copy link

commented Dec 15, 2017

Q A
Bug report? yes
Feature request? no
BC Break report? yes
RFC? no
Symfony version 3.4.2

After "composer update" to migrate from 3.3. to 3.4, the WebServerBundle no longer works.

When i open the site in bowser, i have this error:

PHP Warning: require(index.php): failed to open stream: No such file or directory in vendor/symfony/symfony/src/Symfony/Bundle/WebServerBundle/Resources/router.php on line 42

@abzolv

This comment has been minimized.

Copy link

commented Dec 15, 2017

Same here. I upgraded from 3.4.1.

@remindbg

This comment has been minimized.

Copy link

commented Dec 15, 2017

Same here, fresh new installs

@Simperfit

This comment has been minimized.

Copy link
Contributor

commented Dec 16, 2017

Could you please post a reproducer on github ? Because i've test both symfony-standard and flex (symfony-skeleton) on fresh install and they are both working.

In case you need some help you can read this blog post : https://symfony.com/doc/current/contributing/code/reproducer.html

@abzolv

This comment has been minimized.

Copy link

commented Dec 16, 2017

Here is all you need to do on your local development computer to reproduce the bug:

symfony new testapp 3.4.2
cd testapp
composer require symfony/web-server-bundle
./bin/console server:run

In your web browser address bar, type http://127.0.0.1:8000 and press Enter.

@Simperfit

This comment has been minimized.

Copy link
Contributor

commented Dec 16, 2017

Same as flex :

#( 12/16/17@12:53PM )( hamza@MBP-de-Amrouche ):~/projet/contrib/symfony_reproducer
   cd testapp 
#( 12/16/17@12:53PM )( hamza@MBP-de-Amrouche ):~/projet/contrib/symfony_reproducer/testapp
   composer require symfony/web-server-bundle 
Using version ^4.0 for symfony/web-server-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
    Prefetch start: total: 1
    1/1:    https://codeload.github.com/symfony/web-server-bundle/legacy.zip/bd56cde308dc2b9d2aa6506ee740c0c3853aeb2f
    Finished: success:1, skipped:0, failure:0, total: 1
Package operations: 1 install, 0 updates, 0 removals
  - Installing symfony/web-server-bundle (v4.0.2): Loading from cache
Writing lock file
Generating autoload files
Changelogs summary:

 - symfony/web-server-bundle installed in version v4.0.2
   Release notes: https://github.com/symfony/web-server-bundle/releases/tag/v4.0.2

> Incenteev\ParameterHandler\ScriptHandler::buildParameters
Updating the "app/config/parameters.yml" file
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache

 // Clearing the cache for the dev environment with debug                       
 // true                                                                        

                                                                                
 [OK] Cache for the "dev" environment (debug=true) was successfully cleared.    
                                                                                

> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets

 Trying to install assets as relative symbolic links.

                                                                                
 [OK] No assets were provided by any bundle.                                    
                                                                                

> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget
#( 12/16/17@12:53PM )( hamza@MBP-de-Amrouche ):~/projet/contrib/symfony_reproducer/testapp
   ./bin/console server:run 

                                                                                                                        
 [ERROR] The document root directory "/Users/hamza/projet/contrib/symfony_reproducer/testapp/public" does not exist.    
                                                                                                                        

By the way, if you use the symfony installer you don't need to require de web-server-bundle since it requires symfony/symfony (so the whole framework).

Event following what you said still cannot reproduce. I get an error, I can't run the server.

@Valix could you please send us the steps to get this error ? Are you using windows or linux ? Do you a have empty public folder ?

@abzolv

This comment has been minimized.

Copy link

commented Dec 16, 2017

@Simperfit, why are you testing this under V4.0.2? The problem is in 3.4.2. The web server works perfectly in 3.4.1. It is broken in 3.4.2.

@Simperfit

This comment has been minimized.

Copy link
Contributor

commented Dec 16, 2017

I'm not testing this under 4.0.2, it's using the composer it install 4.0.2, not using composer you have already the webserver installed and it works.
capture d ecran 2017-12-16 a 13 35 37

@abzolv

This comment has been minimized.

Copy link

commented Dec 16, 2017

Here is what I do and what I get:

symfony new testapp 3.4.2
Downloading Symfony...
[snip]
Preparing project...
✔ Symfony 3.4.2 was successfully installed. Now you can:
* Change your current directory to /data/testapp
* Configure your application in app/config/parameters.yml file.

* Run your application:
    1. Execute the php bin/console server:run command.
    2. Browse to the http://localhost:8000 URL.

* Read the documentation at http://symfony.com/doc

Local1:data abzolv$ cd testapp
Local1:data abzolv$ ./bin/console server:run

[OK] Server listening on http://127.0.0.1:8000

// Quit the server with CONTROL-C.

PHP 7.0.16 Development Server started at Sat Dec 16 08:43:01 2017
Listening on http://127.0.0.1:8000
Document root is /data/testapp/web
Press Ctrl-C to quit.

In the web browser I get the error:

Fatal error: require(): Failed opening required 'index.php' (include_path='.:') in /data/testapp/vendor/symfony/symfony/src/Symfony/Bundle/WebServerBundle/Resources/router.php on line 42


Points to note:

  • I have never installed V4, only V3.x
  • This is on MacOS
@Simperfit

This comment has been minimized.

Copy link
Contributor

commented Dec 16, 2017

@abzolv Thanks! With the version of PHP I can reproduce the bug. Ill try to look into this to understand why with this version of php the behaviour is wrong.

@Simperfit

This comment has been minimized.

Copy link
Contributor

commented Dec 16, 2017

So,

I debugged the behaviour and it seems to affect only php 7.0 (with php >= php 7.0).
What we can see is tha the putenv https://github.com/symfony/symfony/blob/3.4/src/Symfony/Bundle/WebServerBundle/WebServerConfig.php#L35 does not work because the getenv
returns false. Only on 3.4 (I did not test 4.0 atm)

@fabpot @nicolas-grekas Do you have an idea on how to fix this since it seems that is a bug with php 7.0 only.
Maybe we could default to an existing file but since this is a performance path it can be critical to add condition.

@chalasr

This comment has been minimized.

Copy link
Member

commented Dec 16, 2017

Could using $_ENV help (for both setting and getting the var)?

@pacogomezarnal

This comment has been minimized.

Copy link

commented Dec 16, 2017

I'am developing with php 5.6.31 and I have the same problem

@pacogomezarnal

This comment has been minimized.

Copy link

commented Dec 16, 2017

php symfony new project 3.4
Downloading Symfony...

6.1 MiB/6.1 MiB ============================================================  100%

Preparing project...

OK Symfony 3.4.2 was successfully installed. Now you can:

php bin/console server:run

Warning: require(index.php): failed to open stream: No such file or directory in C:\symfony4\project\vendor\symfony\symfony\src\Symfony\Bundle\WebServerBundle\Resources\router.php on line 42

Fatal error: require(): Failed opening required 'index.php' (include_path='C:\xampp\php\PEAR') in C:\symfony4\project\vendor\symfony\symfony\src\Symfony\Bundle\WebServerBundle\Resources\router.php on line 42

@Simperfit

This comment has been minimized.

Copy link
Contributor

commented Dec 16, 2017

Thanks for the report, I think this is the same bug @pacogomezarnal.

@pacogomezarnal

This comment has been minimized.

Copy link

commented Dec 16, 2017

Thanks

@Simperfit

This comment has been minimized.

Copy link
Contributor

commented Dec 16, 2017

@chalasr I'm trying a fix with $_ENV

@Simperfit

This comment has been minimized.

Copy link
Contributor

commented Dec 16, 2017

Thanks @chalasr it's working !

@abzolv

This comment has been minimized.

Copy link

commented Dec 16, 2017

@Simperfit, just to potentially safe you a lot of headscrathing... according to http://php.net/manual/en/function.putenv.php#98540 putenv/getenv and $_ENV are two completely distinct environment stores.

@Simperfit

This comment has been minimized.

Copy link
Contributor

commented Dec 16, 2017

@abzolv Thanks but I did know that ^^

@pacogomezarnal

This comment has been minimized.

Copy link

commented Dec 17, 2017

Looking for inside code, the bug is in
proyecto3_4\vendor\symfony\symfony\src\Symfony\Bundle\WebServerBundle\Resources\router.php
require $script;

If you do a var_dum($script), the result is index.php and is incorrect, because the correct file is app_dev.php

@pacogomezarnal

This comment has been minimized.

Copy link

commented Dec 17, 2017

But if you print APP_FRONT_CONTROLLER from WebServerConfig, the enviroment variable is correct because it prints app_dev.php

@Simperfit

This comment has been minimized.

Copy link
Contributor

commented Dec 17, 2017

Yes please check #25523. It fixes the bug

@pacogomezarnal

This comment has been minimized.

Copy link

commented Dec 17, 2017

OK. Thank you

@pacogomezarnal

This comment has been minimized.

Copy link

commented Dec 17, 2017

Checked and working

@abzolv

This comment has been minimized.

Copy link

commented Dec 19, 2017

I want to ask a question here that's been bugging me for a few days.

Does this issue perhaps reveal an important gap in Symfony's quality assurance processes?

Most people would not use the leading or bleeding edge versions of either Symfony or PHP to develop large production systems. Most people would use the latest LTS versions.

This bug was caused by a combination of PHP and Symfony versions that were not the latest and greatest versions in the development cycles of either. And Symfony's QA processes missed it, even though the bug rendered the WebserverBundle completely inoperative.

So, the question is, going forward, how can it be assured that combinations of older versions get properly QA'd to prevent similar bugs from slipping through in versions that are likely used by most people for serious production work?

I wouldn't want to venture any recommendations because I'm not familiar with Symfony's existing QA procedures.

@nicolas-grekas

This comment has been minimized.

Copy link
Member

commented Dec 19, 2017

@abzolv WebServerBundle is a pure dev dependency. The thing that is broken is a helper that never runs at prod time. It may happen that this is less tested than the more critical parts of the code (every other part of the code base is more critical for sure.)

nicolas-grekas added a commit that referenced this issue Dec 20, 2017

bug #25523 [WebServerBundle] fix a bug where require would not requir…
…e the good file because of env (Simperfit)

This PR was merged into the 3.3 branch.

Discussion
----------

[WebServerBundle] fix a bug where require would not require the good file because of env

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | #25515
| License       | MIT
| Doc PR        |

This fixes a bug with putenv that could be not working on certain version of php. (>=7.0.0).

Commits
-------

bfeee1f [WebServerBundle] fix a bug where require would not require the good file because of env
@johnrivelt

This comment has been minimized.

Copy link

commented Dec 27, 2017

I have still the same issue.
It seems that symfony lts still indicates old dependencies which has a bug.

php: 7.0.0 / 7.2.0
os : windows 10

php symfony new project lts => 3.4.2

php bin/console server:run

Warning: require(index.php): failed to open stream: No such file or directory in ~\vendor\symfony\symfony\src\Symfony\Bundle\WebServerBundle\Resources\router.php on line 42

Fatal error: require(): Failed opening required 'index.php' (include_path='C:\wamp\php\PEAR') in ~\vendor\symfony\symfony\src\Symfony\Bundle\WebServerBundle\Resources\router.php on line 42

@xabbuh

This comment has been minimized.

Copy link
Member

commented Dec 27, 2017

The PR solving this was not part of a release yet. You would need up to depend on 3.4@dev for now.

@damienalexandre

This comment has been minimized.

Copy link
Contributor

commented Dec 28, 2017

With Symfony 3.4, you can also run APP_FRONT_CONTROLLER=app.php php bin/console server:start instead of installing a not tagged version.

@ghost

This comment has been minimized.

Copy link

commented Jan 4, 2018

When I generated a new Bundle I faced this problem : How can I resolve it for symfony 3.4

Warning: require(index.php): failed to open stream: No such file or directory in C:\wamp64\www\symfony_project\vendor\symfony\symfony\src\Symfony\Bundle\WebServerBundle\Resources\router.php on line 42

Fatal error: require(): Failed opening required 'index.php' (include_path='.;C:\php\pear') in C:\wamp64\www\symfony_project\vendor\symfony\symfony\src\Symfony\Bundle\WebServerBundle\Resources\router.php on line 42

@Simperfit

This comment has been minimized.

Copy link
Contributor

commented Jan 4, 2018

@cyx-veera like @damienalexandre said, or wait for a new release containing the patch.

@godoakbrutal

This comment has been minimized.

Copy link

commented Feb 20, 2018

This work for me

  1. clear all cache (remove folder cache in var folder) and do clear:cache
  2. restart server server:stop then make a new server:start

sorry if I was wrong :)

@abderrahimoukhrib

This comment has been minimized.

Copy link

commented Feb 6, 2019

This work for me

$script = isset($_ENV['APP_FRONT_CONTROLLER']) ? $_ENV['APP_FRONT_CONTROLLER'] : 'app_dev.php';

Line 33 : app_dev.php instead of index.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.