0

I'm trying to configure Drush on my shared host and any time I try to do anything it fails as follows:

bash-3.2$ drush cache-clear all
require_once(CRM/Core/ClassLoader.php): failed to open stream: No    [warning]
such file or directory civicrm.settings.php:497

Fatal error: require_once(): Failed opening required 'CRM/Core/ClassLoader.php' (include_path='.:/var/sites/j/example.net/public_html/sites/all/modules/civicrm:/var/sites/j/example.net/public_html/sites/all/modules/civicrm/packages:.:/usr/newage/lib/php') in /var/sites/c/beta.example.net/public_html/sites/default/civicrm.settings.php on line 497
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: require_once(): Failed opening required
'CRM/Core/ClassLoader.php'
(include_path='.:/var/sites/j/example.net/public_html/sites/all/modules/civicrm:/var/sites/j/example.net/public_html/sites/all/modules/civicrm/packages:.:/usr/newage/lib/php')
in
/var/sites/c/beta.example.net/public_html/sites/default/civicrm.settings.php,
line 497

I found a suggestion in this answer to add the civicrm_root variable to the require_once 'CRM/Core/ClassLoader.php'; line in civicrm.settings.php, but that just results in the slightly more verbose:

bash-3.2$ drush cache-clear all
require_once(/var/sites/j/example.net/public_html/sites/all/modules/civicrm/CRM/Core/ClassLoader.php):[warning]
failed to open stream: No such file or directory
civicrm.settings.php:497

Fatal error: require_once(): Failed opening required '/var/sites/j/example.net/public_html/sites/all/modules/civicrm/CRM/Core/ClassLoader.php' (include_path='.:/var/sites/j/example.net/public_html/sites/all/modules/civicrm:/var/sites/j/example.net/public_html/sites/all/modules/civicrm/packages:.:/usr/newage/lib/php') in /var/sites/c/beta.example.net/public_html/sites/default/civicrm.settings.php on line 497
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: require_once(): Failed opening required
'/var/sites/j/example.net/public_html/sites/all/modules/civicrm/CRM/Core/ClassLoader.php'
(include_path='.:/var/sites/j/example.net/public_html/sites/all/modules/civicrm:/var/sites/j/example.net/public_html/sites/all/modules/civicrm/packages:.:/usr/newage/lib/php')
in
/var/sites/c/beta.example.net/public_html/sites/default/civicrm.settings.php,
line 497

For reasons I don't really understand my site seems to operate from the path

/var/sites/j/example.net/public_html

when as far as I can tell from the access the host gives us, I'm always working in

/var/sites/c/beta.example.net/public_html

Based on advice in a previous answer, I'd configured the $civicrm_root variable to reflect the first and the site has always worked fine since then. For the sake of this, I tried putting that full second path in the require_once 'CRM/Core/ClassLoader.php'; line and then got:

bash-3.2$ drush cache-clear all
Could not locate CiviCRM codebase. Make sure CiviCRM settings file   [error]
has correct information.

Why, then, can it normally find the rest of the codebase, but not that one file?

Edit 6:31pm BST: I tried updating the $civicrm_root variable directly with the second path and it does now seem to work. But then I suspect the problems from the previous question that led me to set it as it was will reoccur. I guess the site itself must be using a different operational path than I get over SSL. Is there a way I can configure Drush to always remember and use a specific version of $civicrm_root that's different from the version in civicrm.settings.php?

Edit 22nd December: drush status seems to correctly show that second path as the Drupal root. I've created a drushrc.php file in sites/default which is now defining the URL, but the problem remains the same.

bash-3.2$ drush status
 Drupal version         :  7.74                                                 
 Site URI               :  https://example.net                        
 Database driver        :  mysql                                                
 Database hostname      :  10.169.0.172                                         
 Database port          :                                                       
 Database username      :  example_user                                     
 Database name          :  example_drupal                                         
 Database               :  Connected                                            
 Drupal bootstrap       :  Successful                                           
 Drupal user            :                                                       
 Default theme          :  nexus                                                
 Administration theme   :  seven                                                
 PHP executable         :  /usr/bin/php-7.3                                     
 PHP configuration      :                                                       
 PHP OS                 :  Linux                                                
 Drush script           :  /var/sites/c/beta.example.net/drush/dru 
                           sh.php                                               
 Drush version          :  8.4.5                                                
 Drush temp directory   :  /tmp                                                 
 Drush configuration    :  /var/sites/c/beta.example.net/public_ht 
                           ml/sites/default/drushrc.php                         
 Drush alias files      :                                                       
 Install profile        :  standard                                             
 Drupal root            :  /var/sites/c/civicrm.jesusshapedpeople.net/public_ht 
                           ml                                                   
 Drupal Settings File   :  sites/default/settings.php                           
 Site path              :  sites/default                                        
 File directory path    :  sites/default/files                                  
 Private file           :  sites/default/files/private                          
 directory path                                                                 
 Temporary file         :  tmp                                                  
 directory path          

It seems Drush is taking the full path of civicrm_root specified in civicrm.settings.php regardless of how it's own Drupal root is specified. Is there a way I can overwrite that variable in this file? Just adding

$civicrm_root = '/var/sites/c/beta.example.net/public_html/sites/all/modules/civicrm';

at the end doesn't seem to do it...

2
  • Try passing the -l http://example.com option to drush? – Demerit Dec 18 '20 at 18:44
  • @Demerit Sadly that gives exactly the same error. – somnolentsurfer Dec 22 '20 at 14:00
0

When your cli environment is different from the environment your web server is in, it makes a few things tricky.

Setting the drush document root and url would be the first thing to try. You don't want to mess up the working civicrm.settings.php file that is used for the webserver to find the code.

There are options to drush that let you save configurations, you probably want to research that.

1
  • Thanks. I've updated the question with the results of drush status. The Drupal Root and URL appear to be set correctly. I've created a drushrc.php file and tried setting the config in there, but drush still seems to be drawing the path it needs directly from civicrm.settings.php. Any tips on what I should google to find what you're talking about? – somnolentsurfer Dec 22 '20 at 16:27

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.