DRUPAL_ROOT undefined on module installation I try to install the live_agent module. When I go to enable the module, I get the following errors:


  Notice: Use of undefined constant DRUPAL_ROOT - assumed 'DRUPAL_ROOT' in /sites/all/modules/live_agent/live_agent.module on line 319
  
  Warning: require_once(DRUPAL_ROOT/includes/errors.inc) [function.require-once]: failed to open stream: No such file or directory in /sites/all/modules/live_agent/live_agent.module on line 319
  
  Fatal error: require_once() [function.require]: Failed opening required 'DRUPAL_ROOT/includes/errors.inc' (include_path='.:/usr/share/pear:/usr/share/php') in /sites/all/modules/live_agent/live_agent.module on line 319


The code causing the error is the following one.

 /* 318 */ function live_agent_buttons_form(&amp;$form_state) {
 /* 319 */   global $base_url;
 /* 320 */ 
 /* 321 */   $settings = new liveagent_Settings();
 /* 322 */   $la_buttons_grid = $settings-&gt;getButtonsGridRecordset();
 /* 323 */   $recordset = $la_buttons_grid-&gt;toArray();
 /* 324 */ 
             // ...
 /* 373 */ }


Any help on debugging this would be greatly appreciated.
The error about the undefined constant DRUPAL_ROOT could be caused from the index.php file that is corrupted, or that is returned corrupted from APC, or similar extension. DRUPAL_ROOT is always defined when Drupal bootstraps.

/**
 * Root directory of Drupal installation.
 */
define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
menu_execute_active_handler();


As for why the error message is reported for that module when a function that doesn't contain any reference to the constant is executed, I think that is caused from the autoload function Drupal registers, drupal_autoload_class(), which is trying to load the file containing the class.