I am using Drupal 8.1.3, Drush 8.1.7, and PHP 5.6.2 on a Mac OS X.

I've installed a fresh Drupal 8 site demo from Zircon on a local MAMP stack. When I try to run watchdog show, and some other commands, I get the following error:

Drupal\Core\DependencyInjection\ContainerNotInitializedException: \Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container. in Drupal::getContainer() (line 129 of /Applications/MAMP/htdocs/example/docroot/core/lib/Drupal.php).

I was able to run the following commands successfully:

drush cr
drush version
drush status

I've just updated to latest version of drush, but this is my first time seeing this error.

Also, drush pm-update returns:

Command pm-update needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command.


Here is the output of drush status:

Drupal version         :  8.1.3                                                                                                      
 Site URI               :  http://default                                                                                             
 Database driver        :  mysql                                                                                                      
 Database hostname      :  localhost                                                                                                  
 Database port          :  3306                                                                                                       
 Database username      :  ******                                                                                                    
 Database name          :  ******                                                                                                    
 PHP configuration      :  /Applications/MAMP/bin/php/php5.6.2/conf/php.ini                                                           
 PHP OS                 :  Darwin                                                                                                     
 Drush script           :  /usr/local/bin/drush                                                                                       
 Drush version          :  8.1.7                                                                                                      
 Drush temp directory   :  /tmp                                                                                                       
 Drush configuration    :                                                                                                             
 Drush alias files      :                                                                                                             
 Drupal root            :  /Applications/MAMP/htdocs/example/docroot                                                                  
 Drupal Settings File   :  sites/default/settings.php                                                                                 
 Site path              :  sites/default                                                                                              
 Sync config path       :  sites/default/files/config_pHswhbzOqqMuWn7c6kYMbap6DKcyXxItrvbtsCQeJYoQ04xTi19pOZywbF8KZ8Wrx43VrLsVMw/sync

The user interface does work.

Update: I checked some of my other projects (Drupal 7 and 8 sites), for which drush worked perfectly fine on, and they are throwing errors with the same Drush command, which tells me it's probably not a Drupal 8 problem but probably due to changes I made on my dev platform. I had installed Composer and upgraded Drush, and other related changes.

  • 2
    Hard to provide any useful hints without seeing a backtrace. the UI works? You could try to debug it, see e.g. lullabot.com/articles/…. what is the actual output of drush status (make sure to mask any possibly secret info like passwords or so)
    – Berdir
    Nov 19, 2016 at 7:48
  • The backtrace is hundreds of lines long so I am linking it here: docs.google.com/document/d/…
    – Christia
    Nov 19, 2016 at 8:38

1 Answer 1


I had the same problem with Drush throwing an exception for a test site on localhost. I was able to access the site from the browser, from where I didn't get any error message, not even a message from a exception handler. This puzzled me, since the site was clearly working.

It started to work again when I changed the file permissions for the Drupal files. The user account I was using to execute the command line was missing the permission to write in some directories.

  • I checked that the user is the same. I also checked some of my other projects, which were working fine, which are now throwing the same error with this drush command. This tells me that it's something I changed on my computer or dev environment and not related to Drupal. I had updated Drush, installed composer and created a symlink to mysql for my convenience. Could it have been any of those things?
    – Christia
    Nov 19, 2016 at 8:55
  • 1
    Do you execute the command line using the same user/group used to run the web server?
    – apaderno
    Nov 19, 2016 at 8:59
  • I ran ps aux | egrep '(apache|httpd)' and found the the user was different. I sudo chown -R [user] [docroot] but I still get the error.
    – Christia
    Nov 19, 2016 at 9:10
  • 1
    You need to change the file permissions too. I don't recall on which directories I changed them, but I recall it was the write permission for the user account I use to run the command line on my Mac Mini.
    – apaderno
    Nov 19, 2016 at 10:18
  • What is curious is that my other projects, which I didn't touch today, are also throwing errors now. I think this has to go beyond file permissions within one Drupal installation. Is there a common Drush file between them all that needs permissions set?
    – Christia
    Nov 19, 2016 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.