Skip to main content
Expands the answer based on the comments.
Source Link
kenorb
  • 14.3k
  • 10
  • 98
  • 168
  • For SQL Server, review README file of SQL Server driver for Drupal 7 to confirm the right requirements and installation steps. See also: Can I use MS SQL?.

  • Make sure that your database client (such as sqlcmd) command exists globally (from the command-line). Otherwise make sure its path is added into your PATH system variable. See: Sqlsqlsrv.php.

  • Clear Drush internal caches and try again:

      drush cc drush
    
  • If you're using a multisite environment, make sure to specify the right Drupal site to use, e.g.

      drush --uri=http://site1.example.com status
    

    or:

      drush -l http://site2.example.com status
    

    Note: By default Drush uses sites/default unless you will run the command in specific sites/ folder.

    Note: To define URI of the Drupal site, set $base_url in your settings file per given site (or drushrc.php).

  • Run drush status (add -d for debugging output) to check whether Drupal root, Database name and Database driver has been detected correctly. If not, run the command again, but in the same folder where is your settings.php file and verify that Drupal Settings File has been recognized. Verify it has the right read permissions

  • Check the output of drush sql-connect command whether it returns the right command and there are no errors.

    If there is no matching SQL Class, this suggests drush can't detect the db driver from your settings file. So confirm the following command returns the current site path (folder containing settings.php):

      drush ev "echo drush_site_path();"
    

    If it's empty, make sure you're running drush command in the right folder and your settings.php exists.

  • Check whether Drupal bootstrap object is properly loaded by:

      drush ev "print_r(drush_get_bootstrap_object());"
    

    If so, check whether your settings file is readable:

      drush ev 'echo file_get_contents(drush_get_bootstrap_object()->conf_path()."/settings.php");
    

    Otherwise if your bootstrap object is EmptyBoot, please review how Drush defines Drupal root as valid (candidates are: DrupalBoot6, DrupalBoot7, DrupalBoot8), for Drupal 7 the logic is as below:

      function valid_root($path) {
        if (!empty($path) && is_dir($path) && file_exists($path . '/index.php')) {
          // Drupal 7 root.
          // We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site
          $candidate = 'includes/common.inc';
          if (file_exists($path . '/' . $candidate) && file_exists($path . '/misc/drupal.js') && file_exists($path . '/modules/field/field.module')) {
            return $candidate;
          }
        }
      }
    

    So make sure that you've the following files present: includes/common.inc, misc/drupal.js and modules/field/field.module in your Drupal root (where $path is your Drupal root, but it can be specified manually by --root=path/to/drupal). Also make sure the files are readable by the user (in case of symlinks, they're pointing to the right files; right permissions in case of network share or Linux file system). Otherwise edit Drupal boot class file (e.g. DrupalBoot7.php, part of Drush) and try to debug the above valid_root() method by checking which condition exactly fails and why.

    Example Drush command to verify whether index.php exists:

      drush ev '$path = drush_get_context("DRUSH_SELECTED_DRUPAL_ROOT"); var_dump(file_exists($path . "/index.php"));'
    
  • Finally check whether SQL class can be loaded by:

      drush ev 'var_dump(drush_sql_get_class());'
    
  • You may consider re-testing in different PHP versions, e.g.

  • For SQL Server, review README file of SQL Server driver for Drupal 7 to confirm the right requirements and installation steps. See also: Can I use MS SQL?.

  • Make sure that your database client (such as sqlcmd) command exists globally (from the command-line). Otherwise make sure its path is added into your PATH system variable. See: Sqlsqlsrv.php.

  • Clear Drush internal caches and try again:

      drush cc drush
    
  • If you're using a multisite environment, make sure to specify the right Drupal site to use, e.g.

      drush --uri=http://site1.example.com status
    

    or:

      drush -l http://site2.example.com status
    

    Note: By default Drush uses sites/default unless you will run the command in specific sites/ folder.

  • Run drush status (add -d for debugging output) to check whether Drupal root, Database name and Database driver has been detected correctly. If not, run the command again, but in the same folder where is your settings.php file and verify that Drupal Settings File has been recognized. Verify it has the right read permissions

  • Check the output of drush sql-connect command whether it returns the right command and there are no errors.

    If there is no matching SQL Class, this suggests drush can't detect the db driver from your settings file. So confirm the following command returns the current site path (folder containing settings.php):

      drush ev "echo drush_site_path();"
    

    If it's empty, make sure you're running drush command in the right folder and your settings.php exists.

  • Check whether Drupal bootstrap object is properly loaded by:

      drush ev "print_r(drush_get_bootstrap_object());"
    

    If so, check whether your settings file is readable:

      drush ev 'echo file_get_contents(drush_get_bootstrap_object()->conf_path()."/settings.php");
    

    Otherwise if your bootstrap object is EmptyBoot, please review how Drush defines Drupal root as valid (candidates are: DrupalBoot6, DrupalBoot7, DrupalBoot8), for Drupal 7 the logic is as below:

      function valid_root($path) {
        if (!empty($path) && is_dir($path) && file_exists($path . '/index.php')) {
          // Drupal 7 root.
          // We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site
          $candidate = 'includes/common.inc';
          if (file_exists($path . '/' . $candidate) && file_exists($path . '/misc/drupal.js') && file_exists($path . '/modules/field/field.module')) {
            return $candidate;
          }
        }
      }
    

    So make sure that you've the following files present: includes/common.inc, misc/drupal.js and modules/field/field.module in your Drupal root (where $path is your Drupal root, but it can be specified manually by --root=path/to/drupal). Also make sure the files are readable by the user (in case of symlinks, they're pointing to the right files; right permissions in case of network share or Linux file system). Otherwise edit Drupal boot class file (e.g. DrupalBoot7.php, part of Drush) and try to debug the above valid_root() method by checking which condition exactly fails and why.

    Example Drush command to verify whether index.php exists:

      drush ev '$path = drush_get_context("DRUSH_SELECTED_DRUPAL_ROOT"); var_dump(file_exists($path . "/index.php"));'
    
  • Finally check whether SQL class can be loaded by:

      drush ev 'var_dump(drush_sql_get_class());'
    
  • You may consider re-testing in different PHP versions, e.g.

  • For SQL Server, review README file of SQL Server driver for Drupal 7 to confirm the right requirements and installation steps. See also: Can I use MS SQL?.

  • Make sure that your database client (such as sqlcmd) command exists globally (from the command-line). Otherwise make sure its path is added into your PATH system variable. See: Sqlsqlsrv.php.

  • Clear Drush internal caches and try again:

      drush cc drush
    
  • If you're using a multisite environment, make sure to specify the right Drupal site to use, e.g.

      drush --uri=http://site1.example.com status
    

    or:

      drush -l http://site2.example.com status
    

    Note: By default Drush uses sites/default unless you will run the command in specific sites/ folder.

    Note: To define URI of the Drupal site, set $base_url in your settings file per given site (or drushrc.php).

  • Run drush status (add -d for debugging output) to check whether Drupal root, Database name and Database driver has been detected correctly. If not, run the command again, but in the same folder where is your settings.php file and verify that Drupal Settings File has been recognized. Verify it has the right read permissions

  • Check the output of drush sql-connect command whether it returns the right command and there are no errors.

    If there is no matching SQL Class, this suggests drush can't detect the db driver from your settings file. So confirm the following command returns the current site path (folder containing settings.php):

      drush ev "echo drush_site_path();"
    

    If it's empty, make sure you're running drush command in the right folder and your settings.php exists.

  • Check whether Drupal bootstrap object is properly loaded by:

      drush ev "print_r(drush_get_bootstrap_object());"
    

    If so, check whether your settings file is readable:

      drush ev 'echo file_get_contents(drush_get_bootstrap_object()->conf_path()."/settings.php");
    

    Otherwise if your bootstrap object is EmptyBoot, please review how Drush defines Drupal root as valid (candidates are: DrupalBoot6, DrupalBoot7, DrupalBoot8), for Drupal 7 the logic is as below:

      function valid_root($path) {
        if (!empty($path) && is_dir($path) && file_exists($path . '/index.php')) {
          // Drupal 7 root.
          // We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site
          $candidate = 'includes/common.inc';
          if (file_exists($path . '/' . $candidate) && file_exists($path . '/misc/drupal.js') && file_exists($path . '/modules/field/field.module')) {
            return $candidate;
          }
        }
      }
    

    So make sure that you've the following files present: includes/common.inc, misc/drupal.js and modules/field/field.module in your Drupal root (where $path is your Drupal root, but it can be specified manually by --root=path/to/drupal). Also make sure the files are readable by the user (in case of symlinks, they're pointing to the right files; right permissions in case of network share or Linux file system). Otherwise edit Drupal boot class file (e.g. DrupalBoot7.php, part of Drush) and try to debug the above valid_root() method by checking which condition exactly fails and why.

    Example Drush command to verify whether index.php exists:

      drush ev '$path = drush_get_context("DRUSH_SELECTED_DRUPAL_ROOT"); var_dump(file_exists($path . "/index.php"));'
    
  • Finally check whether SQL class can be loaded by:

      drush ev 'var_dump(drush_sql_get_class());'
    
  • You may consider re-testing in different PHP versions, e.g.

Expands the answer based on the comments.
Source Link
kenorb
  • 14.3k
  • 10
  • 98
  • 168
  • For SQL Server, review README file of SQL Server driver for Drupal 7 to confirm the right requirements and installation steps. See also: Can I use MS SQL?.

  • Make sure that your database client (such as sqlcmd) command exists globally (from the command-line). Otherwise make sure its path is added into your PATH system variable. See: Sqlsqlsrv.php.

  • Clear Drush internal caches and try again:

      drush cc drush
    
  • If you're using a multisite environment, make sure to specify the right drupalDrupal site to use (by default is default unless you run the command in specific site folder), e.g.

      drush --uri=http://site1.example.com status
    

    or:

      drush -l http://site2.example.com status
    

    Note: By default Drush uses sites/default unless you will run the command in specific sites/ folder.

  • Run drush status (add -d for debugging output) to check whether Drupal root, Database name and Database driver has been detected correctly. If not, run the command again, but in the same folder where is your settings.php file and verify that Drupal Settings File has been recognized. Verify it has the right read permissions

  • Check the output of drush sql-connect command whether it returns the right command and there are no errors.

    If there is no matching SQL Class, this suggests drush can't detect the db driver from your settings file. So confirm the following command returns the current site path (folder containing settings.php):

      drush ev "echo drush_site_path();"
    

    If it's empty, make sure you're running drush command in the right folder and your settings.php exists.

  • Check whether Drupal bootstrap object is properly loaded by:

      drush ev "print_r(drush_get_bootstrap_object());"
    

    If so, check whether your settings file is readable:

      drush ev 'echo file_get_contents(drush_get_bootstrap_object()->conf_path()."/settings.php");
    

    Otherwise if your bootstrap object is EmptyBoot, please review how Drush defines Drupal root as valid (candidates are: DrupalBoot6, DrupalBoot7, DrupalBoot8), for Drupal 7 the logic is as below:

      function valid_root($path) {
        if (!empty($path) && is_dir($path) && file_exists($path . '/index.php')) {
          // Drupal 7 root.
          // We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site
          $candidate = 'includes/common.inc';
          if (file_exists($path . '/' . $candidate) && file_exists($path . '/misc/drupal.js') && file_exists($path . '/modules/field/field.module')) {
            return $candidate;
          }
        }
      }
    

    So make sure that you've the following files present: includes/common.inc, misc/drupal.js and modules/field/field.module in your Drupal root (where $path is your Drupal root, but it can be specified manually by --root=path/to/drupal). Also make sure the files are readable by the user (in case of symlinks, they're pointing to the right files; right permissions in case of network share or Linux file system). Otherwise edit Drupal boot class file (e.g. DrupalBoot7.php, part of Drush) and try to debug the above valid_root() method by checking which condition exactly fails and why.

    Example Drush command to verify whether index.php exists:

      drush ev '$path = drush_get_context("DRUSH_SELECTED_DRUPAL_ROOT"); var_dump(file_exists($path . "/index.php"));'
    
  • Finally check whether SQL class can be loaded by:

      drush ev 'var_dump(drush_sql_get_class());'
    
  • You may consider re-testing in different PHP versions, e.g.

  • For SQL Server, review README file of SQL Server driver for Drupal 7 to confirm the right requirements and installation steps. See also: Can I use MS SQL?.

  • Make sure that your database client (such as sqlcmd) command exists globally (from the command-line). Otherwise make sure its path is added into your PATH system variable. See: Sqlsqlsrv.php.

  • Clear Drush internal caches and try again:

      drush cc drush
    
  • If you're using a multisite environment, make sure to specify the right drupal site to use (by default is default unless you run the command in specific site folder), e.g.

      drush --uri=http://site1.example.com status
    

    or:

      drush -l http://site2.example.com status
    
  • Run drush status (add -d for debugging output) to check whether Drupal root, Database name and Database driver has been detected correctly. If not, run the command again, but in the same folder where is your settings.php file and verify that Drupal Settings File has been recognized. Verify it has the right read permissions

  • Check the output of drush sql-connect command whether it returns the right command and there are no errors.

    If there is no matching SQL Class, this suggests drush can't detect the db driver from your settings file. So confirm the following command returns the current site path (folder containing settings.php):

      drush ev "echo drush_site_path();"
    

    If it's empty, make sure you're running drush command in the right folder and your settings.php exists.

  • Check whether Drupal bootstrap object is properly loaded by:

      drush ev "print_r(drush_get_bootstrap_object());"
    

    If so, check whether your settings file is readable:

      drush ev 'echo file_get_contents(drush_get_bootstrap_object()->conf_path()."/settings.php");
    

    Otherwise if your bootstrap object is EmptyBoot, please review how Drush defines Drupal root as valid (candidates are: DrupalBoot6, DrupalBoot7, DrupalBoot8), for Drupal 7 the logic is as below:

      function valid_root($path) {
        if (!empty($path) && is_dir($path) && file_exists($path . '/index.php')) {
          // Drupal 7 root.
          // We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site
          $candidate = 'includes/common.inc';
          if (file_exists($path . '/' . $candidate) && file_exists($path . '/misc/drupal.js') && file_exists($path . '/modules/field/field.module')) {
            return $candidate;
          }
        }
      }
    

    So make sure that you've the following files present: includes/common.inc, misc/drupal.js and modules/field/field.module in your Drupal root (where $path is your Drupal root, but it can be specified manually by --root=path/to/drupal). Also make sure the files are readable by the user (in case of symlinks, they're pointing to the right files; right permissions in case of network share or Linux file system). Otherwise edit Drupal boot class file (e.g. DrupalBoot7.php, part of Drush) and try to debug the above valid_root() method by checking which condition exactly fails and why.

    Example Drush command to verify whether index.php exists:

      drush ev '$path = drush_get_context("DRUSH_SELECTED_DRUPAL_ROOT"); var_dump(file_exists($path . "/index.php"));'
    
  • Finally check whether SQL class can be loaded by:

      drush ev 'var_dump(drush_sql_get_class());'
    
  • You may consider re-testing in different PHP versions, e.g.

  • For SQL Server, review README file of SQL Server driver for Drupal 7 to confirm the right requirements and installation steps. See also: Can I use MS SQL?.

  • Make sure that your database client (such as sqlcmd) command exists globally (from the command-line). Otherwise make sure its path is added into your PATH system variable. See: Sqlsqlsrv.php.

  • Clear Drush internal caches and try again:

      drush cc drush
    
  • If you're using a multisite environment, make sure to specify the right Drupal site to use, e.g.

      drush --uri=http://site1.example.com status
    

    or:

      drush -l http://site2.example.com status
    

    Note: By default Drush uses sites/default unless you will run the command in specific sites/ folder.

  • Run drush status (add -d for debugging output) to check whether Drupal root, Database name and Database driver has been detected correctly. If not, run the command again, but in the same folder where is your settings.php file and verify that Drupal Settings File has been recognized. Verify it has the right read permissions

  • Check the output of drush sql-connect command whether it returns the right command and there are no errors.

    If there is no matching SQL Class, this suggests drush can't detect the db driver from your settings file. So confirm the following command returns the current site path (folder containing settings.php):

      drush ev "echo drush_site_path();"
    

    If it's empty, make sure you're running drush command in the right folder and your settings.php exists.

  • Check whether Drupal bootstrap object is properly loaded by:

      drush ev "print_r(drush_get_bootstrap_object());"
    

    If so, check whether your settings file is readable:

      drush ev 'echo file_get_contents(drush_get_bootstrap_object()->conf_path()."/settings.php");
    

    Otherwise if your bootstrap object is EmptyBoot, please review how Drush defines Drupal root as valid (candidates are: DrupalBoot6, DrupalBoot7, DrupalBoot8), for Drupal 7 the logic is as below:

      function valid_root($path) {
        if (!empty($path) && is_dir($path) && file_exists($path . '/index.php')) {
          // Drupal 7 root.
          // We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site
          $candidate = 'includes/common.inc';
          if (file_exists($path . '/' . $candidate) && file_exists($path . '/misc/drupal.js') && file_exists($path . '/modules/field/field.module')) {
            return $candidate;
          }
        }
      }
    

    So make sure that you've the following files present: includes/common.inc, misc/drupal.js and modules/field/field.module in your Drupal root (where $path is your Drupal root, but it can be specified manually by --root=path/to/drupal). Also make sure the files are readable by the user (in case of symlinks, they're pointing to the right files; right permissions in case of network share or Linux file system). Otherwise edit Drupal boot class file (e.g. DrupalBoot7.php, part of Drush) and try to debug the above valid_root() method by checking which condition exactly fails and why.

    Example Drush command to verify whether index.php exists:

      drush ev '$path = drush_get_context("DRUSH_SELECTED_DRUPAL_ROOT"); var_dump(file_exists($path . "/index.php"));'
    
  • Finally check whether SQL class can be loaded by:

      drush ev 'var_dump(drush_sql_get_class());'
    
  • You may consider re-testing in different PHP versions, e.g.

Expands the answer based on the comments.
Source Link
kenorb
  • 14.3k
  • 10
  • 98
  • 168
  • For SQL Server, review README file of SQL Server driver for Drupal 7 to confirm the right requirements and installation steps. See also: Can I use MS SQL?.

  • Make sure that your database client (such as sqlcmd) command exists globally (from the command-line). Otherwise make sure its path is added into your PATH system variable. See: Sqlsqlsrv.php.

  • Clear Drush internal caches and try again:

      drush cc drush
    
  • If you're using a multisite environment, make sure to specify the right drupal site to use (by default is default unless you run the command in specific site folder), e.g.

      drush --uri=http://site1.example.com status
    

    or:

      drush -l http://site2.example.com status
    
  • Run drush status (add -d for debugging output) to check whether Drupal root, Database name and Database driver has been detected correctly. If not, run the command again, but in the same folder where is your settings.php file and verify that Drupal Settings File has been recognized. Verify it has the right read permissions

  • Check the output of drush sql-connect command whether it returns the right command and there are no errors.

    If there is no matching SQL Class, this suggests drush can't detect the db driver from your settings file. So confirm the following command returns the current site path (folder containing settings.php):

      drush ev "echo drush_site_path();"
    

    If it's empty, make sure you're running drush command in the right folder and your settings.php exists.

  • Check whether Drupal bootstrap object is properly loaded by:

      drush ev "print_r(drush_get_bootstrap_object());"
    

    If so, check whether your settings file is readable:

      drush ev 'echo file_get_contents(drush_get_bootstrap_object()->conf_path()."/settings.php");
    

    Otherwise if your bootstrap object is EmptyBoot, please review how Drush defines Drupal root as valid (candidates are: DrupalBoot6, DrupalBoot7, DrupalBoot8), for Drupal 7 the logic is as below:

      function valid_root($path) {
        if (!empty($path) && is_dir($path) && file_exists($path . '/index.php')) {
          // Drupal 7 root.
          // We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site
          $candidate = 'includes/common.inc';
          if (file_exists($path . '/' . $candidate) && file_exists($path . '/misc/drupal.js') && file_exists($path . '/modules/field/field.module')) {
            return $candidate;
          }
        }
      }
    

    So make sure that you've the following files present: includes/common.inc, misc/drupal.js and modules/field/field.module in your Drupal root (where $path is your Drupal root, but it can be specified manually by --root=path/to/drupal). Also make sure the files are readable by the user (in case of symlinks, they're pointing to the right files; right permissions in case of network share or Linux file system). Otherwise edit Drupal boot class file (e.g. DrupalBoot7.php, part of Drush) and try to debug the above valid_root() method by checking which condition exactly fails and why.

    Example Drush command to verify whether index.php exists:

      drush ev '$path = drush_get_context("DRUSH_SELECTED_DRUPAL_ROOT"); var_dump(file_exists($path . "/index.php"));'
    
  • Finally check whether SQL class can be loaded by:

      drush ev 'var_dump(drush_sql_get_class());'
    
  • You may consider re-testing in different PHP versions, e.g.

  • For SQL Server, review README file of SQL Server driver for Drupal 7 to confirm the right requirements and installation steps. See also: Can I use MS SQL?.

  • Make sure that your database client (such as sqlcmd) command exists globally (from the command-line). Otherwise make sure its path is added into your PATH system variable. See: Sqlsqlsrv.php.

  • Clear Drush internal caches and try again:

      drush cc drush
    
  • Run drush status (add -d for debugging output) to check whether Drupal root, Database name and Database driver has been detected correctly. If not, run the command again, but in the same folder where is your settings.php file and verify that Drupal Settings File has been recognized. Verify it has the right read permissions

  • Check the output of drush sql-connect command whether it returns the right command and there are no errors.

    If there is no matching SQL Class, this suggests drush can't detect the db driver from your settings file. So confirm the following command returns the current site path (folder containing settings.php):

      drush ev "echo drush_site_path();"
    

    If it's empty, make sure you're running drush command in the right folder and your settings.php exists.

  • Check whether Drupal bootstrap object is properly loaded by:

      drush ev "print_r(drush_get_bootstrap_object());"
    

    If so, check whether your settings file is readable:

      drush ev 'echo file_get_contents(drush_get_bootstrap_object()->conf_path()."/settings.php");
    

    Otherwise if your bootstrap object is EmptyBoot, please review how Drush defines Drupal root as valid (candidates are: DrupalBoot6, DrupalBoot7, DrupalBoot8), for Drupal 7 the logic is as below:

      function valid_root($path) {
        if (!empty($path) && is_dir($path) && file_exists($path . '/index.php')) {
          // Drupal 7 root.
          // We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site
          $candidate = 'includes/common.inc';
          if (file_exists($path . '/' . $candidate) && file_exists($path . '/misc/drupal.js') && file_exists($path . '/modules/field/field.module')) {
            return $candidate;
          }
        }
      }
    

    So make sure that you've the following files present: includes/common.inc, misc/drupal.js and modules/field/field.module in your Drupal root (where $path is your Drupal root, but it can be specified manually by --root=path/to/drupal). Also make sure the files are readable by the user (in case of symlinks, they're pointing to the right files; right permissions in case of network share or Linux file system). Otherwise edit Drupal boot class file (e.g. DrupalBoot7.php, part of Drush) and try to debug the above valid_root() method by checking which condition exactly fails and why.

  • Finally check whether SQL class can be loaded by:

      drush ev 'var_dump(drush_sql_get_class());'
    
  • You may consider re-testing in different PHP versions, e.g.

  • For SQL Server, review README file of SQL Server driver for Drupal 7 to confirm the right requirements and installation steps. See also: Can I use MS SQL?.

  • Make sure that your database client (such as sqlcmd) command exists globally (from the command-line). Otherwise make sure its path is added into your PATH system variable. See: Sqlsqlsrv.php.

  • Clear Drush internal caches and try again:

      drush cc drush
    
  • If you're using a multisite environment, make sure to specify the right drupal site to use (by default is default unless you run the command in specific site folder), e.g.

      drush --uri=http://site1.example.com status
    

    or:

      drush -l http://site2.example.com status
    
  • Run drush status (add -d for debugging output) to check whether Drupal root, Database name and Database driver has been detected correctly. If not, run the command again, but in the same folder where is your settings.php file and verify that Drupal Settings File has been recognized. Verify it has the right read permissions

  • Check the output of drush sql-connect command whether it returns the right command and there are no errors.

    If there is no matching SQL Class, this suggests drush can't detect the db driver from your settings file. So confirm the following command returns the current site path (folder containing settings.php):

      drush ev "echo drush_site_path();"
    

    If it's empty, make sure you're running drush command in the right folder and your settings.php exists.

  • Check whether Drupal bootstrap object is properly loaded by:

      drush ev "print_r(drush_get_bootstrap_object());"
    

    If so, check whether your settings file is readable:

      drush ev 'echo file_get_contents(drush_get_bootstrap_object()->conf_path()."/settings.php");
    

    Otherwise if your bootstrap object is EmptyBoot, please review how Drush defines Drupal root as valid (candidates are: DrupalBoot6, DrupalBoot7, DrupalBoot8), for Drupal 7 the logic is as below:

      function valid_root($path) {
        if (!empty($path) && is_dir($path) && file_exists($path . '/index.php')) {
          // Drupal 7 root.
          // We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site
          $candidate = 'includes/common.inc';
          if (file_exists($path . '/' . $candidate) && file_exists($path . '/misc/drupal.js') && file_exists($path . '/modules/field/field.module')) {
            return $candidate;
          }
        }
      }
    

    So make sure that you've the following files present: includes/common.inc, misc/drupal.js and modules/field/field.module in your Drupal root (where $path is your Drupal root, but it can be specified manually by --root=path/to/drupal). Also make sure the files are readable by the user (in case of symlinks, they're pointing to the right files; right permissions in case of network share or Linux file system). Otherwise edit Drupal boot class file (e.g. DrupalBoot7.php, part of Drush) and try to debug the above valid_root() method by checking which condition exactly fails and why.

    Example Drush command to verify whether index.php exists:

      drush ev '$path = drush_get_context("DRUSH_SELECTED_DRUPAL_ROOT"); var_dump(file_exists($path . "/index.php"));'
    
  • Finally check whether SQL class can be loaded by:

      drush ev 'var_dump(drush_sql_get_class());'
    
  • You may consider re-testing in different PHP versions, e.g.

Expands based on the comment.
Source Link
kenorb
  • 14.3k
  • 10
  • 98
  • 168
Loading
Expands based on the comment.
Source Link
kenorb
  • 14.3k
  • 10
  • 98
  • 168
Loading
added 194 characters in body
Source Link
kenorb
  • 14.3k
  • 10
  • 98
  • 168
Loading
added 194 characters in body
Source Link
kenorb
  • 14.3k
  • 10
  • 98
  • 168
Loading
Source Link
kenorb
  • 14.3k
  • 10
  • 98
  • 168
Loading