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

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

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

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

dustinleblanc opened this issue Mar 21, 2016 · 12 comments
Assignees
Labels

Comments

@dustinleblanc
Copy link

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
Copy link
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

@weitzman
Copy link
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.

@weitzman weitzman changed the title Runserver can't find runserver-prepend.php Runserver can't find runserver-prepend.php when using Phar Apr 7, 2016
@greg-1-anderson
Copy link
Member

@athompso
Copy link

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
Copy link
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.

@weitzman
Copy link
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

@weitzman
Copy link
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.

@jhedstrom
Copy link
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).

@greg-1-anderson
Copy link
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.

@gitressa
Copy link
Contributor

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
Copy link
Member

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

@gitressa
Copy link
Contributor

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?

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

No branches or pull requests

7 participants