When using Drush from a subdirectory, it seems to improperly detect/compute DRUPAL_ROOT.

I thought I tracked it down to _drush_bootstrap_drupal_root(), but I'm really not sure.

Comments

pfrenssen’s picture

Status: Active » Needs review
StatusFileSize
new1.17 KB

This only happens when you are in a subdirectory of the 'core' folder.

The problem is in drush_valid_drupal_root() but originates in drush_locate_root() since this walks up the path and presents each step to drush_valid_drupal_root(). Once we have walked up to the 'core' folder it finds that the 'includes/common.inc' folder exists and returns a match.

We need an additional check here. I solved it by testing if the Symfony framework is present, since this has been introduced in D8 and will probably be around for a while.

webchick’s picture

Status: Needs review » Needs work

Hm. This did not resolve the issue for me.

$ drush en poll
require_once(/Users/abyron/Sites/8.x/core/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php):[warning]
failed to open stream: No such file or directory bootstrap.inc:3021

Fatal error: require_once(): Failed opening required '/Users/abyron/Sites/8.x/core/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php' (include_path='.:/Applications/MAMP/bin/php/php5.3.6/lib/php') in /Users/abyron/Sites/8.x/core/includes/bootstrap.inc on line 3021

Call Stack:
    0.0008     699904   1. {main}() /Users/abyron/drush/drush.php:0
    0.0189    4708096   2. drush_main() /Users/abyron/drush/drush.php:14
    0.6526   17843792   3. _drush_bootstrap_and_dispatch() /Users/abyron/drush/drush.php:59
    0.6848   17854000   4. drush_bootstrap_to_phase() /Users/abyron/drush/drush.php:79
    0.6860   17856536   5. drush_bootstrap() /Users/abyron/drush/includes/bootstrap.inc:308
    0.6865   17857792   6. _drush_bootstrap_drupal_root() /Users/abyron/drush/includes/bootstrap.inc:185
    0.7299   21672360   7. dt() /Users/abyron/drush/includes/bootstrap.inc:696
    0.7299   21672360   8. drupal_classloader() /Users/abyron/drush/includes/output.inc:140

require_once(/Users/abyron/Sites/8.x/core/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php):[warning]
failed to open stream: No such file or directory bootstrap.inc:3021

Fatal error: require_once(): Failed opening required '/Users/abyron/Sites/8.x/core/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php' (include_path='.:/Applications/MAMP/bin/php/php5.3.6/lib/php') in /Users/abyron/Sites/8.x/core/includes/bootstrap.inc on line 3021

Call Stack:
    0.0008     699904   1. {main}() /Users/abyron/drush/drush.php:0
    0.0189    4708096   2. drush_main() /Users/abyron/drush/drush.php:14
    0.6526   17843792   3. _drush_bootstrap_and_dispatch() /Users/abyron/drush/drush.php:59
    0.6848   17854000   4. drush_bootstrap_to_phase() /Users/abyron/drush/drush.php:79
    0.6860   17856536   5. drush_bootstrap() /Users/abyron/drush/includes/bootstrap.inc:308
    0.6865   17857792   6. _drush_bootstrap_drupal_root() /Users/abyron/drush/includes/bootstrap.inc:185
    0.7299   21672360   7. dt() /Users/abyron/drush/includes/bootstrap.inc:696
    0.7299   21672360   8. drupal_classloader() /Users/abyron/drush/includes/output.inc:140
    0.8064   21670944   9. drush_shutdown() /Users/abyron/drush/includes/bootstrap.inc:0
    0.8065   21673200  10. dt() /Users/abyron/drush/includes/bootstrap.inc:1060
    0.8065   21673200  11. drupal_classloader() /Users/abyron/drush/includes/output.inc:140
webchick’s picture

Title: Failed opening required core/core/includes/config.inc in D8 » Drush does not work from within a subdirectory (e.g. /core) in Drupal 8

Re-titling a bit; this isn't just about config.inc (in fact, I don't actually get those errors).

kenorb’s picture