The recent addition of config.storage and config.storage.staging means that before drupal_container() can be called the site's settings.php needs to be read.

The patch attached ensures that drush only uses the t() function when drupal_container() is safe to call.

Currently just typing drush on the CLI in a drupal 8 root directory at HEAD generates the following error:

PHP Fatal error:  Uncaught exception 'Exception' with message 'The configuration directory type <em class="placeholder">active</em> does not exist.' in /Users/alex/dev/sites/drupal8alt.dev/core/includes/bootstrap.inc:496
Stack trace:
#0 /Users/alex/dev/sites/drupal8alt.dev/core/includes/bootstrap.inc(2447): config_get_config_directory('active')
#1 /Users/alex/dev/sites/drupal8alt.dev/core/includes/bootstrap.inc(2675): drupal_container()
#2 /Users/alex/dev/sites/drupal8alt.dev/core/includes/bootstrap.inc(1456): language('language_interf...')
#3 /Users/alex/dev/drush5/includes/output.inc(152): t('Initialized Dru...', Array)
#4 /Users/alex/dev/drush5/includes/bootstrap.inc(698): dt('Initialized Dru...', Array)
#5 /Users/alex/dev/drush5/includes/bootstrap.inc(185): _drush_bootstrap_drupal_root()
#6 /Users/alex/dev/drush5/includes/bootstrap.inc(345): drush_bootstrap(1, 3)
#7 /Users/alex/dev/drush5/commands/core/help.drush.inc(260): drush_bootstrap_max(3)
#8 [internal function]: drush_core_help()
#9 /Users/alex/dev/drush5/includes/c in /Users/alex/dev/sites/drupal8alt.dev/core/includes/bootstrap.inc on line 496

Fatal error: Uncaught exception 'Exception' with message 'The configuration directory type <em class="placeholder">active</em> does not exist.' in /Users/alex/dev/sites/drupal8alt.dev/core/includes/bootstrap.inc on line 496

Exception: The configuration directory type <em class="placeholder">active</em> does not exist. in /Users/alex/dev/sites/drupal8alt.dev/core/includes/bootstrap.inc on line 496

Call Stack:
    0.0004     709584   1. {main}() /Users/alex/dev/drush5/drush.php:0
    0.0155    5153000   2. drush_main() /Users/alex/dev/drush5/drush.php:14
    0.0567   12112712   3. _drush_bootstrap_and_dispatch() /Users/alex/dev/drush5/drush.php:59
    0.0719   12123264   4. drush_dispatch() /Users/alex/dev/drush5/drush.php:90
    0.0985   12142096   5. call_user_func_array() /Users/alex/dev/drush5/includes/command.inc:165
    0.0985   12142464   6. drush_command() /Users/alex/dev/drush5/includes/command.inc:165
    0.0986   12142776   7. _drush_invoke_hooks() /Users/alex/dev/drush5/includes/command.inc:198
    0.0991   12190776   8. call_user_func_array() /Users/alex/dev/drush5/includes/command.inc:324
    0.0991   12191144   9. drush_core_help() /Users/alex/dev/drush5/includes/command.inc:324
    0.0991   12191536  10. drush_bootstrap_max() /Users/alex/dev/drush5/commands/core/help.drush.inc:260
    0.1001   12193544  11. drush_bootstrap() /Users/alex/dev/drush5/includes/bootstrap.inc:345
    0.1006   12195448  12. _drush_bootstrap_drupal_root() /Users/alex/dev/drush5/includes/bootstrap.inc:185
    0.1135   14903224  13. dt() /Users/alex/dev/drush5/includes/bootstrap.inc:698
    0.1139   14999312  14. t() /Users/alex/dev/drush5/includes/output.inc:152
    0.1139   14999776  15. language() /Users/alex/dev/sites/drupal8alt.dev/core/includes/bootstrap.inc:1456
    0.1139   14999856  16. drupal_container() /Users/alex/dev/sites/drupal8alt.dev/core/includes/bootstrap.inc:2675
    0.1164   15776192  17. config_get_config_directory() /Users/alex/dev/sites/drupal8alt.dev/core/includes/bootstrap.inc:2447

Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                                                 [error]
Error: Uncaught exception 'Exception' with message 'The configuration directory type <em class="placeholder">active</em> does not exist.' in /Users/alex/dev/sites/drupal8alt.dev/core/includes/bootstrap.inc:496
Stack trace:
#0 /Users/alex/dev/sites/drupal8alt.dev/core/includes/bootstrap.inc(2447): config_get_config_directory('active')
#1 /Users/alex/dev/sites/drupal8alt.dev/core/includes/bootstrap.inc(2675): drupal_container()
#2 /Users/alex/dev/sites/drupal8alt.dev/core/includes/bootstrap.inc(1456): language('language_interf...')
#3 /Users/alex/dev/drush5/includes/output.inc(152): t('Initialized Dru...', Array)
#4 /Users/alex/dev/drush5/includes/bootstrap.inc(698): dt('Initialized Dru...', Array)
#5 /Users/alex/dev/drush5/includes/bootstrap.inc(185): _drush_bootstrap_drupal_root()
#6 /Users/alex/dev/drush5/includes/bootstrap.inc(345): drush_bootstrap(1, 3)
#7 /Users/alex/dev/drush5/commands/core/help.drush.inc(260): drush_bootstrap_max(3)
#8 [internal function]: drush_core_help()
#9 /Users/alex/dev/drush5/includes/c in /Users/alex/dev/sites/drupal8alt.dev/core/includes/bootstrap.inc, line 496

Comments

alexpott’s picture

Better and safer implementation - tested on Drupal 6,7,8

alexpott’s picture

Doh! uploaded same patch... here goes again...

tim.plunkett’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

I like the $output approach.
Works as expected.

moshe weitzman’s picture

Status: Reviewed & tested by the community » Fixed

This reliance on drupal_container() is getting uglier. We already "fixed" this once.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

psynaptic’s picture

Did this get fixed? I'm getting this error with a fresh Drupal 8.x and Devel 8.x-1.x.

alexpott’s picture

psynaptic’s picture

Thanks for the swift reply, Alex.

It looks like this error. Here's what it spews:

➜  8 git:(drupal-block-subject-to-title-1591806) ✗ drush en -y devel
PHP Fatal error:  Uncaught exception 'Exception' with message 'The configuration directory type <em class="placeholder">active</em> does not exist.' in /Users/psynaptic/repos/drupal/drupal/8/core/includes/bootstrap.inc:530
Stack trace:
#0 /Users/psynaptic/repos/drupal/drupal/8/core/includes/bootstrap.inc(2439): config_get_config_directory('active')
#1 /Users/psynaptic/repos/drupal/drupal/8/core/includes/bootstrap.inc(2703): drupal_container()
#2 /Users/psynaptic/repos/drupal/drupal/8/core/includes/bootstrap.inc(1490): language('language_interf...')
#3 /usr/local/drush/includes/output.inc(142): t('Initialized Dru...', Array)
#4 /usr/local/drush/includes/bootstrap.inc(696): dt('Initialized Dru...', Array)
#5 /usr/local/drush/includes/bootstrap.inc(185): _drush_bootstrap_drupal_root()
#6 /usr/local/drush/includes/bootstrap.inc(308): drush_bootstrap(1, 6)
#7 /usr/local/drush/drush.php(79): drush_bootstrap_to_phase(6)
#8 /usr/local/drush/drush.php(59): _drush_bootstrap_and_dispatch()
#9 /usr/local/drush/drush.php(14): drush_main()
 in /Users/psynaptic/repos/drupal/drupal/8/core/includes/bootstrap.inc on line 530

Fatal error: Uncaught exception 'Exception' with message 'The configuration directory type <em class="placeholder">active</em> does not exist.' in /Users/psynaptic/repos/drupal/drupal/8/core/includes/bootstrap.inc on line 530

Exception: The configuration directory type <em class="placeholder">active</em> does not exist. in /Users/psynaptic/repos/drupal/drupal/8/core/includes/bootstrap.inc on line 530

Call Stack:
    0.0008     709288   1. {main}() /usr/local/drush/drush.php:0
    0.0203    4717192   2. drush_main() /usr/local/drush/drush.php:14
    0.0983   12380064   3. _drush_bootstrap_and_dispatch() /usr/local/drush/drush.php:59
    0.1299   12385376   4. drush_bootstrap_to_phase($max_phase_index = 6) /usr/local/drush/drush.php:79
    0.1323   12387952   5. drush_bootstrap($phase = 1, $phase_max = 6) /usr/local/drush/includes/bootstrap.inc:308
    0.1335   12389216   6. _drush_bootstrap_drupal_root() /usr/local/drush/includes/bootstrap.inc:185
    0.1492   14844080   7. dt($string = 'Initialized Drupal !version root directory at !drupal_root', $args = array ('!version' => '8.0-dev', '!drupal_root' => '/Users/psynaptic/repos/drupal/drupal/8')) /usr/local/drush/includes/bootstrap.inc:696
    0.1498   14928328   8. t($string = 'Initialized Drupal !version root directory at !drupal_root', $args = array ('!version' => '8.0-dev', '!drupal_root' => '/Users/psynaptic/repos/drupal/drupal/8'), $options = ???) /usr/local/drush/includes/output.inc:142
    0.1498   14928632   9. language($type = 'language_interface', $reset = ???) /Users/psynaptic/repos/drupal/drupal/8/core/includes/bootstrap.inc:1490
    0.1499   14928680  10. drupal_container($new_container = ???, $rebuild = ???) /Users/psynaptic/repos/drupal/drupal/8/core/includes/bootstrap.inc:2703
    0.1536   15624496  11. config_get_config_directory($type = 'active') /Users/psynaptic/repos/drupal/drupal/8/core/includes/bootstrap.inc:2439


Variables in local scope (#11):
  $config_directories = NULL
  $path = *uninitialized*
  $test_prefix = FALSE
  $type = 'active'

Drush command terminated abnormally due to an unrecoverable error.                            [error]
Error: Uncaught exception 'Exception' with message 'The configuration directory type <em
class="placeholder">active</em> does not exist.' in
/Users/psynaptic/repos/drupal/drupal/8/core/includes/bootstrap.inc:530
Stack trace:
#0 /Users/psynaptic/repos/drupal/drupal/8/core/includes/bootstrap.inc(2439):
config_get_config_directory('active')
#1 /Users/psynaptic/repos/drupal/drupal/8/core/includes/bootstrap.inc(2703):
drupal_container()
#2 /Users/psynaptic/repos/drupal/drupal/8/core/includes/bootstrap.inc(1490):
language('language_interf...')
#3 /usr/local/drush/includes/output.inc(142): t('Initialized Dru...', Array)
#4 /usr/local/drush/includes/bootstrap.inc(696): dt('Initialized Dru...', Array)
#5 /usr/local/drush/includes/bootstrap.inc(185): _drush_bootstrap_drupal_root()
#6 /usr/local/drush/includes/bootstrap.inc(308): drush_bootstrap(1, 6)
#7 /usr/local/drush/drush.php(79): drush_bootstrap_to_phase(6)
#8 /usr/local/drush/drush.php(59): _drush_bootstrap_and_dispatch()
#9 /usr/local/drush/drush.php(14): drush_main()
 in /Users/psynaptic/repos/drupal/drupal/8/core/includes/bootstrap.inc, line 530
psynaptic’s picture

Hmm.. I just thought of something.

psynaptic’s picture

Ok, I realised I was using an old drush... d'oh.

I'm now getting the new error :)