Drupal Registry Rebuild

Recently on a server I was on I was getting a drush error that would  not let me use drush dl, drush cc, etc… What was most frustrating is that the error was being reported about a site that doesn’t even exist on the server! What to do?

failed to open stream: No such file or directory bootstrap.inc:3066
PHP Fatal error:  require_once(): Failed opening required '/home/WWU/bronsem/cmssites/test/sites/wcedev.atus.wwu.edu/modules/entity/includes/entity.inc' (include_path='.:/usr/share/php5:/usr/share/php5/PEAR') in /srv/www/campusweb/cmssites/test/includes/bootstrap.inc on line 3066
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: require_once(): Failed opening required
(include_path='.:/usr/share/php5:/usr/share/php5/PEAR') in
/srv/www/campusweb/cmssites/test/includes/bootstrap.inc, line 3066


That is a pretty gross error. When that error occurs it can be nigh impossible to get your site running. Awhile ago a colleague, Vid @ Developments, mentioned the drush rr command which is not built into drush. Go to http://drupal.org/project/registry_rebuild and get it. It is super simple, cleans up random cruft like above. Often those types of messages occur when you are removing a module from your sites/sitename/module folder when you want to use the version in sites/all/modules. If you run into errors, give drush rr a whirl.

Steps to install

  1. Navigate to a location where you can run drush commands. For most of us our home directory is fine.
  2. Type “drush dl registry_rebuild” without the quotes and hit enter. Now it is installed. You should see something like: Project registry_rebuild (7.x-1.9) downloaded to /home/WWU/bronsem/.drush/registry_rebuild.                    [success]
    Project registry_rebuild contains 0 modules: .
  3. Now navigate to the site that is causing you issues and run drush rr.

Supposedly you can run the command from a URL as well. That might be useful if you are on a box that doesn’t allow you access to the command line. For full documentation check out the project page.

Wicked cool utility that makes drush even more awesome. Thank you omega8cc, rfay, and  q0rban.


16 thoughts on “Drupal Registry Rebuild

  1. Had this problem, too, when updating entity. Unfortunately the above didn’t help. Running drush rr did something, but then gave the same error below. Ended up having to ftp the module and overwrite. But thanks for the info! 🙂

  2. I ran into this helping a colleague the other day again. Looking in the system table of the DB it showed the entity module as being disabled. Changing the status from 0 to 1 did resolve the issue. Certainly one that we all want resolved. Thanks for the comment.

  3. I actually faced a similar issue while working on one of my clients website and his server was awful. Believe me, I spent hours searching for the solution and finally found it on some forum.

  4. I’m trying to apply a Drupal 7 (core) security update using drush pm-update and it gives the error msg that it can’t open entity.inc.

    I tried drush rr and the pm-update still fails.

    Ayesha posted a solution that involves using FTP, but as a newbie, I’d like to see some detailed steps to do the replacement (including how to properly disable the entity api).
    I have direct access to the server (it’s on my own PC) and have already downloaded the entity module. I am running Drupal 7.28, Windows 7, Apache 2.4, PHP 5.6 as a handler.

  5. Correction to previous post: “Oliver” posted a solution that involves using FTP, but as a newbie, I’d like to see some detailed steps to do the replacement (including how to properly disable the entity api).

  6. Dennis, you could try to disable entity api with drush. $ drush dis entity and it will probably list a bunch of other modules it will need to disable as well. Let it do that and then run your upgrade. Once complete, use $ drush en entity and do that for each module that was disabled to get your site back to normal. You could also not use drush to do the upgrade, and instead follow the instructions in UPGRADE.txt that is in the download of Drupal 7.29. I hope that helps.

  7. Tried your suggestion. My site is now broken. When I try to access it, I get Apache error 500: cannot display page. The log shows only the error code, no reason why.

    Also, when I did the drush dis entity, it seemed to work OK, but when I did the drush en entity, it said I did not have the entity module and offered to install it for me. I let it do that. I hope I can recover by replacing my DB from my backup.

  8. After my initial panic (above) I replaced the settings.php and .htaccess files from my backup (as well as 2 other files I modified Garland.info & template.php inside Garland) and now, when I try to load the site, instead of running the index.php file, the browser wants to open or download it. Opening the file just edits it as if it were a txt file.
    Any clues as to what I should check???

  9. Looking at php_errors.log, I see this: PHP Fatal error: Call to undefined function ctools_include() in \sites\all\modules\field_group\field_group.module on line 1634

    How can I fix that?

    Sorry to bug you with all these posts, but I really wanted to get that security update done.

  10. It sounds like ctools is disabled. Try enabling ctools. Usually when a webserver is trying to download a .php file rather than display it something is misconfigured with the webserver.

  11. sites/all/modules now has both ctools and entity. I’m not getting any php_error.log file anywhere on my system (looked in all of the folders of & in c:\windows & C:\PHP).

    My browser still refuses to run the index.php file. I must be missing a setting somewhere. phpinfo works, as does phpmyadmin, so PHP itself is OK.

  12. I’ve compared the php.ini and httpd.conf files from my test site to my production site and they appear to be the same. The test site fails, but the production site (thank goodness) is still working (although it doesn’t have the update yet).

  13. I should mention that phpinfo() works just fine, as does phpmyadmin. I just can’t get the Drupal [mysite]/index.php to run.

  14. Found the problem. The following lines were in my original .htaccess file:

    # Set the catch-all handler to prevent scripts from being executed.
    SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006

    # Override the handler again if we're run later in the evaluation list.
    SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003

    and WERE working before the update. I commented out those lines and my site is running again.

    Thanks for your suggestions!! They made me start to suspect that working things had changed.

Leave a Reply

Your email address will not be published. Required fields are marked *