totten / civix

CiviCRM Extension Builder
http://civicrm.org/
Other
56 stars 56 forks source link

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

Open brettcs opened 7 years ago

brettcs commented 7 years ago

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

I think the rationale here is:

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.

totten commented 7 years ago

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 commented 7 years ago

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.