Undefined index: name in system_requirements

Undefined index: name in system_requirements

If you Google this error, you will see several different variations of it, each happening on a different line in the system.install file. There are many reasons why you may see this, but in this short article I will show you how to fix the error in one particular case that happened to me.

The full error (notice) message in my case was:

Notice: Undefined index: name in system_requirements() (line 53 of core/modules/system/system.install).

After I spent some time debugging this error, I found that my core.extension config was missing the profile name in the module list. As you can see in the screenshot bellow, the last item in the module list is views, and it should be the profile name with the weight of 1000.

Missing profile name - Drupal 8
Missing profile name - Drupal 8

If you are using the standard profile, then this cannot happen to you due to the way system_requirements() function works. But, if you are using any other profile, then make sure that you have the profile name listed in the module section like this:

Profile name - Drupal 8
Profile name - Drupal 8

The easiest way to fix this is to use the following function. Either write an update hook an execute it (recommended), or just use Devel execute page to run this piece of code.

/**
 * Fixes 'Undefined index: name in system_requirements()' error.
 */
function _fix_undefined_index() {
  $config = \Drupal::configFactory()->getEditable('core.extension');
  $installed_profile = $config->get('profile');

  if ($installed_profile) {
    $modules = $config->get('module');
    if (!isset($modules[$installed_profile])) {
      $modules[$installed_profile] = '1000';
      $config->set('module', $modules)->save();
    }
  }
}

 

About the author

Goran Nikolovski is a highly experienced Drupal developer with an extensive skill set that includes PHP, MySQL, HTML, CSS and Javascript. He has experience with large Drupal sites and Drupal Commerce 2.x integration, and he is author of several Drupal modules.