Answers.Body: <p>The <code>civibuild</code> command is designed to run as a regular shell user (e.g. <code>john</code>) -- without <code>root</code> permissions. The source code should all be owned by the shell-user, and the data files should be owned by a mix of <code>www-data</code>/<code>apache</code>/<code>www</code>/<code>john</code>. No files should should be owned by <code>root</code>.</p>
  
  <p>The exact errors have varied (depending on the revision and the commands used), so I generally run a search to identify files with errant permissions, e.g.</p>
  
  <pre><code>## Searching for files owned by root (or not by john)
  find ~/.npm/ ~/.composer/ ~/.drush/ ~/buildkit/ -user root
  find ~/.npm/ ~/.composer/ ~/.drush/ ~/buildkit/ ! -user $(whoami)
  find ~/.npm/ ~/.composer/ ~/.drush/ ~/buildkit/ ! -user john -a ! -user www-data
  
  ## Changing owner from root to john
  find ~/.npm/ ~/.composer/ ~/.drush/ ~/buildkit/ -user root -exec chown john {} \;
  </code></pre>
  
  <p>Note that this search covers several folders, including:</p>
  
  <ul>
  <li>The caches generated by various build tools (eg <code>npm</code>, <code>composer</code>, <code>drush</code>)</li>
  <li>The caches generated by buildkit (eg <code>~/buildkit/app/tmp</code>)</li>
  <li>The actual build (eg <code>~/buildkit/build/mybuild</code>)</li>
  </ul>
  
  <p>Additionally, if I've recently run <code>amp config</code> to change the permission policy, fixing the permissions on existing files can be pretty fiddly. I find easiest to delete the old build (e.g. <code>civibuild destroy mybuild</code> or <code>rm -rf ~/buildkit/build/mybuild</code>) and then recreate it.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-30T13:39:37.847Z
Answers.Text: Thanks Tim - I think that last one might have caused it.
Answers.UserDisplayName: JohnFF
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-02T02:17:45.050Z
Answers.Text: Also ~/.config and ~/.npm need updating to have you as their owner. I found using civibuild create with the --force parameter helped me out. You shouldn't use sudo when running civibuild create.
Answers.UserDisplayName: JohnFF
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-29T07:03:18.837Z
Answers.LastActivityDate: 2015-11-29T07:03:18.837Z
Answers.UserDisplayName: Tim Otten
Body: <p>I've encountered a problem (only recently) with buildkit, where when it comes time for me to run:</p>
  
  <p><em>~/buildkit/bin/civibuild install "civi46" --url "<a href="http://civi46" rel="nofollow">http://civi46</a>" --admin-pass "password" --web-root "/var/www/civi46"</em></p>
  
  <p>I get</p>
  
  <p><em>++ CMS_DB_HOSTPORT=127.0.0.1:3306
  ++ pushd /var/www/civi46
  ++ '[' -f sites/default/settings.php ']'
  ++ rm -f sites/default/settings.php
  rm: cannot remove `sites/default/settings.php': Permission denied</em></p>
  
  <p>But when I run </p>
  
  <p><em>sudo ~/buildkit/bin/civibuild install "civi46" --url "<a href="http://civi46" rel="nofollow">http://civi46</a>" --admin-pass "password" --web-root "/var/www/civi46"</em></p>
  
  <p>I get </p>
  
  <p><em>+ bower install -f
  bower ESUDO         Cannot be run with sudo
  Additional error details:
  Since bower is a user command, there is no need to execute it with superuser permissions.
  If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs.
  <a href="http://www.joyent.com/blog/installing-node-and-npm" rel="nofollow">http://www.joyent.com/blog/installing-node-and-npm</a>
  <a href="https://gist.github.com/isaacs/579814" rel="nofollow">https://gist.github.com/isaacs/579814</a>
  You can however run a command with sudo using --allow-root option</em></p>
  
  <p>This takes place even if I (shudder) set settings.php to have 777.</p>
  
  <p>Even if I try to install civi manually after that, it is missing the files lang.php and civicrm-version.php. </p>
  
  <p>With these copied from elsewhere, and the correct install details, clicking install results in "cannot lock table civicrm_acl - doesn't exist". Of course it doesn't exist. I need you to create it, silly install.php!</p>
  
Tags: <civicrm-buildkit>
Title: Buildkit Issue - permissions?
ThreadText: # Buildkit Issue - permissions?
  
  (Asked by: username_0 on 2015-11-29)
  
  I've encountered a problem (only recently) with buildkit, where when it comes time for me to run:
  
  *~/buildkit/bin/civibuild install "civi46" --url "<http://civi46>" --admin-pass "password" --web-root "/var/www/civi46"*
  
  I get
  
  *++ CMS\_DB\_HOSTPORT=127.0.0.1:3306
  ++ pushd /var/www/civi46
  ++ '[' -f sites/default/settings.php ']'
  ++ rm -f sites/default/settings.php
  rm: cannot remove `sites/default/settings.php': Permission denied*
  
  But when I run
  
  *sudo ~/buildkit/bin/civibuild install "civi46" --url "<http://civi46>" --admin-pass "password" --web-root "/var/www/civi46"*
  
  I get
  
  *+ bower install -f
  bower ESUDO Cannot be run with sudo
  Additional error details:
  Since bower is a user command, there is no need to execute it with superuser permissions.
  If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs.
  <http://www.joyent.com/blog/installing-node-and-npm>
  <https://gist.github.com/isaacs/579814>
  You can however run a command with sudo using --allow-root option*
  
  This takes place even if I (shudder) set settings.php to have 777.
  
  Even if I try to install civi manually after that, it is missing the files lang.php and civicrm-version.php.
  
  With these copied from elsewhere, and the correct install details, clicking install results in "cannot lock table civicrm\_acl - doesn't exist". Of course it doesn't exist. I need you to create it, silly install.php!
  
  **Tags:** civicrm-buildkit
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-11-29. Score: 1 | Accepted answer
  
  The `civibuild` command is designed to run as a regular shell user (e.g. `john`) -- without `root` permissions. The source code should all be owned by the shell-user, and the data files should be owned by a mix of `www-data`/`apache`/`www`/`john`. No files should should be owned by `root`.
  
  The exact errors have varied (depending on the revision and the commands used), so I generally run a search to identify files with errant permissions, e.g.
  
  ```
  ## Searching for files owned by root (or not by john)
  find ~/.npm/ ~/.composer/ ~/.drush/ ~/buildkit/ -user root
  find ~/.npm/ ~/.composer/ ~/.drush/ ~/buildkit/ ! -user $(whoami)
  find ~/.npm/ ~/.composer/ ~/.drush/ ~/buildkit/ ! -user john -a ! -user www-data
  
  ## Changing owner from root to john
  find ~/.npm/ ~/.composer/ ~/.drush/ ~/buildkit/ -user root -exec chown john {} \;
  
  ```
  
  Note that this search covers several folders, including:
  
  * The caches generated by various build tools (eg `npm`, `composer`, `drush`)
  * The caches generated by buildkit (eg `~/buildkit/app/tmp`)
  * The actual build (eg `~/buildkit/build/mybuild`)
  
  Additionally, if I've recently run `amp config` to change the permission policy, fixing the permissions on existing files can be pretty fiddly. I find easiest to delete the old build (e.g. `civibuild destroy mybuild` or `rm -rf ~/buildkit/build/mybuild`) and then recreate it.
  
  > **Comments:**
  > **username_0**: Thanks Tim - I think that last one might have caused it.  
  > **username_0**: Also ~/.config and ~/.npm need updating to have you as their owner. I found using civibuild create with the --force parameter helped me out. You shouldn't use sudo when running civibuild create.  
  
  ---
  
  