Answers.Body: <p>When your cli environment is different from the environment your web server is in, it makes a few things tricky.</p>
  <p>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.</p>
  <p>There are options to drush that let you save configurations, you probably want to research that.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-22T16:27:30.767Z
Answers.Text: 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?
Answers.UserDisplayName: somnolentsurfer
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-18T19:09:38.347Z
Answers.LastActivityDate: 2020-12-18T19:09:38.347Z
Answers.UserDisplayName: Alan Dixon
Body: <p>I'm trying to configure Drush on my shared host and any time I try to do anything it fails as follows:</p>
  <pre><code>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
  </code></pre>
  <p>I found a suggestion in <a href="https://civicrm.stackexchange.com/questions/35053/error-require-once-failed-opening-required-crm-core-classloader-php">this answer</a> to add the civicrm_root variable to the <code>require_once 'CRM/Core/ClassLoader.php';</code> line in civicrm.settings.php, but that just results in the slightly more verbose:</p>
  <pre><code>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
  </code></pre>
  <p>For reasons I don't really understand my site seems to operate from the path</p>
  <pre><code>/var/sites/j/example.net/public_html
  </code></pre>
  <p>when as far as I can tell from the access the host gives us, I'm always working in</p>
  <pre><code>/var/sites/c/beta.example.net/public_html
  </code></pre>
  <p>Based on advice in <a href="https://civicrm.stackexchange.com/questions/35209/resource-url-problem">a previous answer</a>, 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 <code>require_once 'CRM/Core/ClassLoader.php';</code> line and then got:</p>
  <pre><code>bash-3.2$ drush cache-clear all
  Could not locate CiviCRM codebase. Make sure CiviCRM settings file   [error]
  has correct information.
  </code></pre>
  <p>Why, then, can it normally find the rest of the codebase, but not that one file?</p>
  <p><strong>Edit 6:31pm BST:</strong> 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?</p>
  <p><strong>Edit 22nd December:</strong> <code>drush status</code> 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.</p>
  <pre><code>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          
  </code></pre>
  <p>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</p>
  <pre><code>$civicrm_root = '/var/sites/c/beta.example.net/public_html/sites/all/modules/civicrm';
  </code></pre>
  <p>at the end doesn't seem to do it...</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-18T18:44:24.597Z
Comments.Text: Try passing the `-l http://example.com` option to drush?
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-22T14:00:14.793Z
Comments.Text: @Demerit Sadly that gives exactly the same error.
Comments.UserDisplayName: somnolentsurfer
Tags: <core><drush><paths>
Title: Drush cannot locate CRM/Core/ClassLoader.php
ThreadText: # Drush cannot locate CRM/Core/ClassLoader.php
  
  (Asked by: username_0 on 2020-12-18)
  
  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...
  
  **Tags:** core, drush, paths
  
  > **Comments:**
  > **username_1**: Try passing the `-l http://example.com` option to drush?  
  > **username_0**: @username_1 Sadly that gives exactly the same error.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-12-18. Score: 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.
  
  > **Comments:**
  > **username_0**: 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?  
  
  ---
  
  