Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obscure errors when run outside CMS root (i.e., because the extensions directory is outside it) #80

Open
brettcs opened this issue Sep 27, 2016 · 2 comments

Comments

@brettcs
Copy link

brettcs commented Sep 27, 2016

I'm running a CiviCRM system installed on Debian 8 ("jessie", current stable) and its drupal7 package. The filesystem is laid out like this:

  • Apache serves Drupal out of /usr/share/drupal7.
  • /usr/share/drupal7/sites is a symlink to /etc/drupal/7/sites, which came with a default subdirectory. It looks like this:
    % ls -l /etc/drupal/7/sites/default/
    total 48
    -rw-r--r-- 1 www-data www-data 17693 Sep 26 17:34 civicrm.settings.php
    -rw-r----- 1 root     www-data  1645 Sep 13 11:44 dbconfig.php
    lrwxrwxrwx 1 root     root        22 Jun 15 19:47 files -> /var/lib/drupal7/files
    lrwxrwxrwx 1 root     root        25 Sep 13 13:47 modules -> /var/lib/drupal7/modules/
    lrwxrwxrwx 1 root     root        24 Sep 13 16:11 private -> /var/lib/drupal7/private
    -rw-r--r-- 1 root     root     18599 Jun 15 19:47 settings.php
  • /var/lib/drupal7 has subdirectories for those symlinks, plus a backups subdirectory.

I think the rationale here is:

  • The Drupal code lives under /usr and is controlled by apt.
  • Small Drupal configuration files live under /etc and are controlled by the sysadmin.
  • Files managed by Drupal directly (including modules) live under /var and are controlled by the Drupal code.

In CiviCRM, Administer→Directories→Extensions Directory is set to [civicrm.files]/ext/.

Because of all this, it seems like the right place to run civix is under /var/lib/drupal7/files/ext. But because that's outside the Drupal root, it doesn't work, even if you set CIVICRM_SETTINGS:

shell% pwd
/var/lib/drupal7/files/ext
shell% CIVICRM_SETTINGS=/etc/drupal/7/sites/default/civicrm.settings.php civix generate:module org.brettcsmith.testb
License set to AGPL-3.0 (authored by Brett Smith <brettcsmith@brettcsmith.org>)
If this is in error, please correct info.xml and LICENSE.txt
Initalize module org.brettcsmith.testb
Write org.brettcsmith.testb/info.xml
Write org.brettcsmith.testb/testb.php
Write org.brettcsmith.testb/testb.civix.php
Write org.brettcsmith.testb/LICENSE.txt
<br />Sorry, could not locate bootstrap.inc\n
shell% pushd org.brettcsmith.testb
/var/lib/drupal7/files/ext/org.brettcsmith.testb /var/lib/drupal7/files/ext
shell% ls -l
total 72
drwx------ 2 brett brett  4096 Sep 27 11:15 build
drwx------ 3 brett brett  4096 Sep 27 11:15 CRM
-rw------- 1 brett brett   816 Sep 27 11:15 info.xml
-rw------- 1 brett brett 34753 Sep 27 11:15 LICENSE.txt
drwx------ 2 brett brett  4096 Sep 27 11:15 templates
-rw------- 1 brett brett 10066 Sep 27 11:15 testb.civix.php
-rw------- 1 brett brett  4074 Sep 27 11:15 testb.php
drwx------ 2 brett brett  4096 Sep 27 11:15 xml
shell% CIVICRM_SETTINGS=/etc/drupal/7/sites/default/civicrm.settings.php civix generate:case-type "Test Case"
<br />Sorry, could not locate bootstrap.inc\n
shell% ls -l xml/
total 0

It would be nice if civix could provide better error reporting or guidance in this case. I'm going to edit the wiki page to emphasize this, but having help directly in the tool would be even better.

@brettcs brettcs changed the title Obscure errors when run outside CMS root (i.e., because the extensions directory it outside it) Obscure errors when run outside CMS root (i.e., because the extensions directory is outside it) Sep 27, 2016
@totten
Copy link
Owner

totten commented Oct 19, 2016

FWIW, the search algorithm which figures out how to bootstrap is not in civix proper -- it comes the utility/library cv (esp. https://github.com/civicrm/cv/blob/master/src/Bootstrap.php ).

@totten
Copy link
Owner

totten commented Oct 19, 2016

Have you tried constructing the PATH to the civicrm.settings.php in different ways?

For example, if /usr/share/drupal7 is the nominal root of the project, then maybe CIVICRM_SETTINGS=/usr/share/drupal7/sites/default/civicrm.settings.php would work better? That way there's at least a theoretical possibility of discovering the path to the actual Drupal root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants