Answers.Body: <p>There seem to be two concerns here - how to get <code>mytestbuild</code> working again - and how to get <code>regen.sh</code> to work.</p>
  
  <h1>Get <code>mytestbuild</code> working</h1>
  
  <p>The quickfix is to drop the table <code>civicrm_install_canary</code>.</p>
  
  <p>The more general fix is to put your codebase to a pristine state (e.g. no local changes/patches; check out the official upstream branch; <a href="https://civicrm.org/blogs/totten/developer-tip-managing-multiple-git-repositories" rel="nofollow"><code>git scan status</code></a> may help). Then you can create a pristine DB using one of these commands:</p>
  
  <ul>
  <li><code>civibuild restore mytestbuild</code> - This is faster -- it loads a SQL snapshot from the last time you ran <code>civibuild</code>.</li>
  <li><code>civibuild reinstall mytestbuild</code> - This is slower -- it drops the Drupal+Civi databases, deletes any config files, and recreates them.</li>
  </ul>
  
  <h1>Get <code>regen.sh</code> working</h1>
  
  <p>This appears to be a regression affecting <code>regen.sh</code>. To determine this, I did a few things:</p>
  
  <ol>
  <li>Checkout the latest code from <code>master</code> and run regen.sh. See the same problem.</li>
  <li>Clear out uncommitted changes (e.g. <code>git checkout -- sql/civicrm_generated.mysql</code>)</li>
  <li>Repeat above, but checkout tag <code>4.7.0</code> instead of branch <code>master</code>. (When jumping among different versions, I usually use <code>./bin/givi checkout &lt;TAG&gt;</code> because that checks out corresponding tags in <code>packages/</code>, <code>drupal/</code>, etc. The need to )</li>
  </ol>
  
  <p>After spot-checking a few tags, I determined the problem arose somewhere after 4.7.0 and before 4.7.2. Since the context involves <code>bin/</code> and the error involves <code>CRM/Utils/System</code>, we can make an educated guess that there was a change in one of those folders and skim the log:</p>
  
  <pre><code>git log 4.7.0..4.7.2 bin/
  git log 4.7.0..4.7.2 CRM/Utils/System
  git log -p 4.7.0..4.7.2 bin/
  git log -p 4.7.0..4.7.2 CRM/Utils/System
  </code></pre>
  
  <p>I'm pretty sure that the regression occurred due to <a href="https://github.com/civicrm/civicrm-core/commit/40d5632a25086d7c963538f2b6daf2a2546e16a6" rel="nofollow">https://github.com/civicrm/civicrm-core/commit/40d5632a25086d7c963538f2b6daf2a2546e16a6</a> ; undoing that patch allows <code>regen.sh</code> to run,  but you'd need to read/think a bit more figure out a proper fix.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-23T22:48:13.007Z
Answers.Text: Follow up: https://github.com/civicrm/civicrm-core/pull/8435
Answers.UserDisplayName: Tim Otten
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-24T07:34:14.400Z
Answers.Text: Checked out `4.7.0` tag and it worked. Thanks :)
Answers.UserDisplayName: Dilip Raj Baral
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-23T20:29:59.293Z
Answers.LastActivityDate: 2016-05-23T20:29:59.293Z
Answers.UserDisplayName: Tim Otten
Body: <p>So I was following this <a href="https://wiki.civicrm.org/confluence/display/CRMDOC/Settings+Reference#SettingsReference-AddingANewSettingtoCiviCRMCore" rel="nofollow">doc</a> to add a new setting which asked me to run <code>bin/regen.sh</code> script. But running the script failed with the following error:</p>
  
  <pre><code>PHP Fatal error:  Call to undefined function db_query() in /opt/buildkit/build/mytestbuild/sites/all/modules/civicrm/CRM/Utils/System/DrupalBase.php on line 303
  </code></pre>
  
  <p>Now I cannot access CiviCRM at all. I get the following message. Drupal works fine though.</p>
  
  <pre><code>The website encountered an unexpected error. Please try again later.
  Error message
  CRM_Core_Exception: Found installation canary. This suggests that something went wrong with tracking installation process. Please post to forum or JIRA. in Civi\Core\InstallationCanary::check() (line 53 of /opt/buildkit/build/mytestbuild/sites/all/modules/civicrm/Civi/Core/InstallationCanary.php).
  </code></pre>
  
Tags: <database><settings>
Title: regen.sh - Call to undefined function db_query()
ThreadText: # regen.sh - Call to undefined function db_query()
  
  (Asked by: username_0 on 2016-05-23)
  
  So I was following this doc to add a new setting which asked me to run bin/regen.sh script. But running the script failed with the following error:
  PHP Fatal error:  Call to undefined function db_query() in /opt/buildkit/build/mytestbuild/sites/all/modules/civicrm/CRM/Utils/System/DrupalBase.php on line 303
  
  Now I cannot access CiviCRM at all. I get the following message. Drupal works fine though.
  The website encountered an unexpected error. Please try again later.
  Error message
  CRM_Core_Exception: Found installation canary. This suggests that something went wrong with tracking installation process. Please post to forum or JIRA. in Civi\Core\InstallationCanary::check() (line 53 of /opt/buildkit/build/mytestbuild/sites/all/modules/civicrm/Civi/Core/InstallationCanary.php).
  
  **Tags:** database, settings
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-05-23. Score: 1 | Accepted answer
  
  There seem to be two concerns here - how to get mytestbuild working again - and how to get regen.sh to work.
  Get mytestbuild working
  The quickfix is to drop the table civicrm_install_canary.
  The more general fix is to put your codebase to a pristine state (e.g. no local changes/patches; check out the official upstream branch; git scan status may help). Then you can create a pristine DB using one of these commands:
  
  civibuild restore mytestbuild - This is faster -- it loads a SQL snapshot from the last time you ran civibuild.
  civibuild reinstall mytestbuild - This is slower -- it drops the Drupal+Civi databases, deletes any config files, and recreates them.
  
  Get regen.sh working
  This appears to be a regression affecting regen.sh. To determine this, I did a few things:
  
  Checkout the latest code from master and run regen.sh. See the same problem.
  Clear out uncommitted changes (e.g. git checkout -- sql/civicrm_generated.mysql)
  Repeat above, but checkout tag 4.7.0 instead of branch master. (When jumping among different versions, I usually use ./bin/givi checkout  because that checks out corresponding tags in packages/, drupal/, etc. The need to )
  
  After spot-checking a few tags, I determined the problem arose somewhere after 4.7.0 and before 4.7.2. Since the context involves bin/ and the error involves CRM/Utils/System, we can make an educated guess that there was a change in one of those folders and skim the log:
  git log 4.7.0..4.7.2 bin/
  git log 4.7.0..4.7.2 CRM/Utils/System
  git log -p 4.7.0..4.7.2 bin/
  git log -p 4.7.0..4.7.2 CRM/Utils/System
  
  I'm pretty sure that the regression occurred due to https://github.com/civicrm/civicrm-core/commit/40d5632a25086d7c963538f2b6daf2a2546e16a6 ; undoing that patch allows regen.sh to run,  but you'd need to read/think a bit more figure out a proper fix.
  
  > **Comments:**
  > **username_1**: Follow up: https://github.com/civicrm/civicrm-core/pull/8435  
  > **username_0**: Checked out `4.7.0` tag and it worked. Thanks :)  
  
  ---
  
  