Answers.Body: <p>It's possible with cv that that file is parsed before cms bootstrap.</p>
  <p>But in any case I would just replace that line with the full path. In a normal install it just puts in the full path for that line.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-01T20:49:27.850Z
Answers.Text: Yeah, I think that's what's happening. The problem is the dir are different on my local env vs my host so having it dynamic to the env is useful.
Answers.UserDisplayName: jphelan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-01T22:12:00.590Z
Answers.Text: There are a couple ways to handle. One is change to the line to be `include '/path/outside/the/tree/civicrm.settings.local.php';` and put your local settings in there. Then the main civicrm.settings.php are identical. Another is use environment variables and read them in civicrm.setting.php, like `defined('DRUPAL_ROOT') ? DRUPAL_ROOT : getenv('LOCAL_DRUPAL_ROOT');`
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-01T14:42:12.273Z
Answers.LastActivityDate: 2023-12-01T14:42:12.273Z
Answers.UserDisplayName: Demerit
Body: <p>I'm trying to run cron with cv and I get this error. The site itself loads fine.</p>
  <pre><code>$ cv api job.execute --user=admin
  
  In civicrm.settings.php line 97:
                                      
    Undefined constant &quot;DRUPAL_ROOT&quot;  
                                      
  
  api3 [--in IN] [--out OUT] [--flat [FLAT]] [-T|--out=table] [-I|--out=list] [--level LEVEL] [--hostname HOSTNAME] [-t|--test] [-U|--user USER] [--] &lt;Entity.action&gt; [&lt;key=value&gt;...]
  </code></pre>
  <p>Line 97 is</p>
  <pre><code>$civicrm_paths['civicrm.files']['path'] = DRUPAL_ROOT . '/files/civicrm';
  </code></pre>
  <p>Why would cv not has access to the DRUPAL_ROOT constant? We're on Drupal 10.</p>
  
Tags: <drupal><cron><cv>
Title: Undefined constant "DRUPAL_ROOT" In civicrm.settings.php when running cv api job.execute
ThreadText: # Undefined constant "DRUPAL_ROOT" In civicrm.settings.php when running cv api job.execute
  
  (Asked by: username_0 on 2023-12-01)
  
  I'm trying to run cron with cv and I get this error. The site itself loads fine.
  
  ```
  $ cv api job.execute --user=admin
  
  In civicrm.settings.php line 97:
                                      
    Undefined constant "DRUPAL_ROOT"  
                                      
  
  api3 [--in IN] [--out OUT] [--flat [FLAT]] [-T|--out=table] [-I|--out=list] [--level LEVEL] [--hostname HOSTNAME] [-t|--test] [-U|--user USER] [--] <Entity.action> [<key=value>...]
  
  ```
  
  Line 97 is
  
  ```
  $civicrm_paths['civicrm.files']['path'] = DRUPAL_ROOT . '/files/civicrm';
  
  ```
  
  Why would cv not has access to the DRUPAL\_ROOT constant? We're on Drupal 10.
  
  **Tags:** drupal, cron, cv
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-12-01. Score: 0
  
  It's possible with cv that that file is parsed before cms bootstrap.
  
  But in any case I would just replace that line with the full path. In a normal install it just puts in the full path for that line.
  
  > **Comments:**
  > **username_0**: Yeah, I think that's what's happening. The problem is the dir are different on my local env vs my host so having it dynamic to the env is useful.  
  > **username_1**: There are a couple ways to handle. One is change to the line to be `include '/path/outside/the/tree/civicrm.settings.local.php';` and put your local settings in there. Then the main civicrm.settings.php are identical. Another is use environment variables and read them in civicrm.setting.php, like `defined('DRUPAL_ROOT') ? DRUPAL_ROOT : getenv('LOCAL_DRUPAL_ROOT');`  
  
  ---
  
  