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

Runserver can't find runserver-prepend.php when using Phar #2090

Closed
dustinleblanc opened this Issue Mar 21, 2016 · 12 comments

Comments

Projects
None yet
7 participants
@dustinleblanc

dustinleblanc commented Mar 21, 2016

Since my latest install of drush via the phar file I am no longer able to start a development server from drush as I get this error anytime a request comes in:

[Mon Mar 21 12:02:30 2016] PHP Fatal error:  Unknown: Failed opening required 'phar:///usr/local/bin/drush/commands/runserver/runserver-prepend.php' (include_path='.:') in Unknown on line 0

Installation via composer seems to be happy as a clam. For the time being, it looks like I will use drush via composer global require drush/drush but I know that somewhere down the road I will likely run into a problem (as I did having Drush and the Laravel installer living side-by-side in my home .composer dir). Any ideas why the phar file is having an issue loading the server prepend file?

@weitzman

This comment has been minimized.

Show comment
Hide comment
@weitzman

weitzman Mar 22, 2016

Member

I'm seeing a similar error even when not using the phar. Hope someone can debug this.

Warning: include(): Failed opening 'index.php' for inclusion (include_path='.:/Applications/Dev Desktop/common/pear:/usr/lib/php') in /Users/moshe.weitzman/c/h/drush/commands/runserver/d8-rs-router.php on line 36
Member

weitzman commented Mar 22, 2016

I'm seeing a similar error even when not using the phar. Hope someone can debug this.

Warning: include(): Failed opening 'index.php' for inclusion (include_path='.:/Applications/Dev Desktop/common/pear:/usr/lib/php') in /Users/moshe.weitzman/c/h/drush/commands/runserver/d8-rs-router.php on line 36
@weitzman

This comment has been minimized.

Show comment
Hide comment
@weitzman

weitzman Mar 23, 2016

Member

I just fixed my error which is in a different file than yours. Perhaps you can try the unstable phar and see if your error is now fixed. Save http://files.drush.org/drush-unstable.phar to your host and give it a try.

Member

weitzman commented Mar 23, 2016

I just fixed my error which is in a different file than yours. Perhaps you can try the unstable phar and see if your error is now fixed. Save http://files.drush.org/drush-unstable.phar to your host and give it a try.

@weitzman weitzman changed the title from Runserver can't find runserver-prepend.php to Runserver can't find runserver-prepend.php when using Phar Apr 7, 2016

@greg-1-anderson

This comment has been minimized.

Show comment
Hide comment
@athompso

This comment has been minimized.

Show comment
Hide comment
@athompso

athompso Apr 11, 2016

Works fine as long as a matching file with the .phar extension exists.
So if I wget drush-unstable, for example, and move it to /usr/local/bin/drush, runserver fails.
But if I move it to /usr/local/bin/drush.phar and symlink drush.phar to drush, then it all works great with or without composer.

I don't see anything in the PHP Phar docs that says the filename has to end in ".phar" (in fact there are examples suggesting otherwise), but given the normal state of PHP docs that doesn't surprise me.

athompso commented Apr 11, 2016

Works fine as long as a matching file with the .phar extension exists.
So if I wget drush-unstable, for example, and move it to /usr/local/bin/drush, runserver fails.
But if I move it to /usr/local/bin/drush.phar and symlink drush.phar to drush, then it all works great with or without composer.

I don't see anything in the PHP Phar docs that says the filename has to end in ".phar" (in fact there are examples suggesting otherwise), but given the normal state of PHP docs that doesn't surprise me.

@greg-1-anderson

This comment has been minimized.

Show comment
Hide comment
@greg-1-anderson

greg-1-anderson Apr 11, 2016

Member

@athompso: Thanks for diagnosing that and finding the workaround. I think it might be better if we explicitly check to see that we are running from a .phar, and, if so, copy the prepend file out to a real file in the filesystem, so the .phar name and location do not have to be so exacting.

Member

greg-1-anderson commented Apr 11, 2016

@athompso: Thanks for diagnosing that and finding the workaround. I think it might be better if we explicitly check to see that we are running from a .phar, and, if so, copy the prepend file out to a real file in the filesystem, so the .phar name and location do not have to be so exacting.

@weitzman

This comment has been minimized.

Show comment
Hide comment
@weitzman

weitzman Apr 13, 2016

Member

Not sure its related, but once I rename drush.phar to drush, I get a fatal error. I can rename it to other names even ones without a .phar extension and I get success. Only drush fails. This sounds like an opcache problem as per http://php.net/manual/en/phar.mapphar.php#113377. However, setting opcache.enable_cli=0 in php.ini did not help.

Here is the actual error:

~/tmp/tmp2 $ ./drush st
PHP Warning:  Phar::mapPhar(/Users/moshe.weitzman/tmp/tmp2/drush): failed to open stream: Too many open files in /Users/moshe.weitzman/tmp/tmp2/drush on line 9
PHP Stack trace:
PHP   1. {main}() /Users/moshe.weitzman/tmp/tmp2/drush:0
PHP   2. Phar::mapPhar() /Users/moshe.weitzman/tmp/tmp2/drush:9

Warning: Phar::mapPhar(/Users/moshe.weitzman/tmp/tmp2/drush): failed to open stream: Too many open files in /Users/moshe.weitzman/tmp/tmp2/drush on line 9

Call Stack:
    0.0029     125820   1. {main}() /Users/moshe.weitzman/tmp/tmp2/drush:0
    0.0030     125896   2. Phar::mapPhar() /Users/moshe.weitzman/tmp/tmp2/drush:9

PHP Fatal error:  Uncaught exception 'PharException' with message 'unable to open phar for reading "/Users/moshe.weitzman/tmp/tmp2/drush"' in /Users/moshe.weitzman/tmp/tmp2/drush:9
Stack trace:
#0 /Users/moshe.weitzman/tmp/tmp2/drush(9): Phar::mapPhar('drush.phar')
#1 {main}
  thrown in /Users/moshe.weitzman/tmp/tmp2/drush on line 9

Fatal error: Uncaught exception 'PharException' with message 'unable to open phar for reading "/Users/moshe.weitzman/tmp/tmp2/drush"' in /Users/moshe.weitzman/tmp/tmp2/drush on line 9

PharException: unable to open phar for reading "/Users/moshe.weitzman/tmp/tmp2/drush" in /Users/moshe.weitzman/tmp/tmp2/drush on line 9

Call Stack:
    0.0029     125820   1. {main}() /Users/moshe.weitzman/tmp/tmp2/drush:0
    0.0030     125896   2. Phar::mapPhar() /Users/moshe.weitzman/tmp/tmp2/drush:9
Member

weitzman commented Apr 13, 2016

Not sure its related, but once I rename drush.phar to drush, I get a fatal error. I can rename it to other names even ones without a .phar extension and I get success. Only drush fails. This sounds like an opcache problem as per http://php.net/manual/en/phar.mapphar.php#113377. However, setting opcache.enable_cli=0 in php.ini did not help.

Here is the actual error:

~/tmp/tmp2 $ ./drush st
PHP Warning:  Phar::mapPhar(/Users/moshe.weitzman/tmp/tmp2/drush): failed to open stream: Too many open files in /Users/moshe.weitzman/tmp/tmp2/drush on line 9
PHP Stack trace:
PHP   1. {main}() /Users/moshe.weitzman/tmp/tmp2/drush:0
PHP   2. Phar::mapPhar() /Users/moshe.weitzman/tmp/tmp2/drush:9

Warning: Phar::mapPhar(/Users/moshe.weitzman/tmp/tmp2/drush): failed to open stream: Too many open files in /Users/moshe.weitzman/tmp/tmp2/drush on line 9

Call Stack:
    0.0029     125820   1. {main}() /Users/moshe.weitzman/tmp/tmp2/drush:0
    0.0030     125896   2. Phar::mapPhar() /Users/moshe.weitzman/tmp/tmp2/drush:9

PHP Fatal error:  Uncaught exception 'PharException' with message 'unable to open phar for reading "/Users/moshe.weitzman/tmp/tmp2/drush"' in /Users/moshe.weitzman/tmp/tmp2/drush:9
Stack trace:
#0 /Users/moshe.weitzman/tmp/tmp2/drush(9): Phar::mapPhar('drush.phar')
#1 {main}
  thrown in /Users/moshe.weitzman/tmp/tmp2/drush on line 9

Fatal error: Uncaught exception 'PharException' with message 'unable to open phar for reading "/Users/moshe.weitzman/tmp/tmp2/drush"' in /Users/moshe.weitzman/tmp/tmp2/drush on line 9

PharException: unable to open phar for reading "/Users/moshe.weitzman/tmp/tmp2/drush" in /Users/moshe.weitzman/tmp/tmp2/drush on line 9

Call Stack:
    0.0029     125820   1. {main}() /Users/moshe.weitzman/tmp/tmp2/drush:0
    0.0030     125896   2. Phar::mapPhar() /Users/moshe.weitzman/tmp/tmp2/drush:9
@weitzman

This comment has been minimized.

Show comment
Hide comment
@weitzman

weitzman Apr 20, 2016

Member

My problem was using an older version of xdebug. I tried with PHP7 and no xdebug and no more Too many files error. But I'm still seeing errors under the conditions described above. Hopefully someone else can help reproduce and fix this.

Member

weitzman commented Apr 20, 2016

My problem was using an older version of xdebug. I tried with PHP7 and no xdebug and no more Too many files error. But I'm still seeing errors under the conditions described above. Hopefully someone else can help reproduce and fix this.

@jhedstrom

This comment has been minimized.

Show comment
Hide comment
@jhedstrom

jhedstrom May 4, 2016

Member

I'm getting this fatal error in 8.1.0 since this went in when running runserver:

Error: Class 'Drush' not found in drush_core_runserver() (line 140 of /path/drush/commands/runserver/runserver.drush.inc).
Member

jhedstrom commented May 4, 2016

I'm getting this fatal error in 8.1.0 since this went in when running runserver:

Error: Class 'Drush' not found in drush_core_runserver() (line 140 of /path/drush/commands/runserver/runserver.drush.inc).
@greg-1-anderson

This comment has been minimized.

Show comment
Hide comment
@greg-1-anderson

greg-1-anderson May 4, 2016

Member

Haven't tried to reproduce @jhedstrom's problem, but this sort of message can often happen if you git checkout between different versions of Drush without running composer install. Also, I think @weitzman said that he recently fixed a runserver bug, so ensure you have the very latest HEAD.

Member

greg-1-anderson commented May 4, 2016

Haven't tried to reproduce @jhedstrom's problem, but this sort of message can often happen if you git checkout between different versions of Drush without running composer install. Also, I think @weitzman said that he recently fixed a runserver bug, so ensure you have the very latest HEAD.

@gitressa

This comment has been minimized.

Show comment
Hide comment
@gitressa

gitressa Jul 11, 2016

I had the same issue, updating to the latest Drush version fixed it, following this guide: http://drupal.stackexchange.com/questions/197480/drush-8-raises-an-error-while-running-drush-runserver/197508#197508

Using Ubuntu, my symlink (the last command) in stead was ln -s ~/.config/composer/vendor/bin/drush /usr/local/bin/drush.

gitressa commented Jul 11, 2016

I had the same issue, updating to the latest Drush version fixed it, following this guide: http://drupal.stackexchange.com/questions/197480/drush-8-raises-an-error-while-running-drush-runserver/197508#197508

Using Ubuntu, my symlink (the last command) in stead was ln -s ~/.config/composer/vendor/bin/drush /usr/local/bin/drush.

@weitzman

This comment has been minimized.

Show comment
Hide comment
@weitzman

weitzman Jul 12, 2016

Member

Not clear if bug is still present. If so, please reopen.

Member

weitzman commented Jul 12, 2016

Not clear if bug is still present. If so, please reopen.

@weitzman weitzman closed this Jul 12, 2016

@gitressa

This comment has been minimized.

Show comment
Hide comment
@gitressa

gitressa Jul 12, 2016

It does not work with the version of Drush you get by following the standard install procedure here:
http://docs.drush.org/en/master/install/

It works if you install Drush via composer, using the procedure outlined on drupal.stackexchange.com.

Perhaps it is not a bug, as much as a need for the documentation to be updated to use Composer for the installation?

gitressa commented Jul 12, 2016

It does not work with the version of Drush you get by following the standard install procedure here:
http://docs.drush.org/en/master/install/

It works if you install Drush via composer, using the procedure outlined on drupal.stackexchange.com.

Perhaps it is not a bug, as much as a need for the documentation to be updated to use Composer for the installation?

mikeker added a commit to mikeker/drush that referenced this issue Aug 10, 2017

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