after hours trying to solve this issue by myself and searching for solutions in Google I thought that maybe someone may already faced this.

Scenario: I am running drush site-install The installation goes well until it hits a hook_cron (don't really know why) and tries to instantiate a a class. If I run drush cron on an installed site it works as a charm as is only when I am installing the site that this happens.

I use PSR-0 to bootstrap the namespaces and the implementation looks much like this:

 * Implements hook_boot().
function MY_MODULE_boot() {
  //Autoload classes PSR-0
  $namespaces = array(
    'COMPANY\MY_MODULE'     => array(__DIR__ . '/lib'),

 * Registers a class namespace with the Composer autoloader
 * @param  array  $namespaces
function MY_MODULE_register_class_namespace(array $namespaces = array()){
  static $loader = null;
  if (!$loader) {
    $loader = require_once realpath('.') . '/vendor/autoload.php';

  foreach ($namespaces as $namespace => $namespace_path) {
    $loader->add($namespace, $namespace_path);

This is the error I get in the console:

Drush command terminated abnormally due to an unrecoverable error.                                                                                              [error]
Error: Class 'COMPANY\MY_MODULE\Repository\MYCLASSRepository' not found in
<path to module>, line 588

I would really appreciate any help with this one. Thanks in advance and sorry about my English.


Apparently there is an issue with the way Drupal bootstraps when doing a fresh install. I solved the issue by adding a call to:


Hope it helps you if you come up with the same issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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