It would be handy if we could provide a location for drush.ini via Env variable. I was in a situation where I needed an ini for just an ad hoc request and I didn't want to disturb other drush users who were logged in with same account on same server. Assigning to Greg.

Comments

greg.1.anderson’s picture

Status: Active » Needs review
StatusFileSize
new2.95 KB

In the past, we held off on such additions because there were already a couple of ways to set php options (php.ini or drush.ini in a location Drush searched for); however, I think that the ideal mechanism for setting php options is dependent on what you are trying to accomplish, and it is therefore valuable to be flexible in this area.

Therefore, for consideration, the attached patch allows the user to specify PHP_INI, DRUSH_INI or PHP_OPTIONS in environment variables, as desired.

greg.1.anderson’s picture

StatusFileSize
new2.65 KB

Same patch, but with my debug 'echo' removed. :p

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Changes look good. I'd like a comment like # Use the DRUSH_PHP environment variable if it is available. in every place where we now honor env variables.

  1. Do we have somewhere to document this?
  2. I think this shell script is complex enough for tests. Maybe we could think of a way to do that. Not a prerequisite for this issue.
greg.1.anderson’s picture

Status: Reviewed & tested by the community » Fixed

Committed #2, then added some documentation in 6b46616.

No tests yet.

greg.1.anderson’s picture

Title: Honor an environment variable for location of drush.ini » Manage environment variables used in Drush script in tests and backend invoke
Status: Fixed » Active
StatusFileSize
new5.96 KB

Here is the beginning of some work to better manage environment variables in Drush tests and in backend invoke. This will allow us to test the Drush script, and to specify environment values to use with a site in its site alias.

greg.1.anderson’s picture

Status: Active » Needs review

#5 is finished enough for one test to work, so could be reviewed and committed if desired.

greg.1.anderson’s picture

Pay no attention to that out-of-place $expected in the functional test.

greg.1.anderson’s picture

There are failures in #5, such as:

6) coreCase::testRsyncPercentFiles
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-Calling system(rsync -e 'ssh ' -akz --yes --invoke /tmp/drush-sandbox/web/sites/dev/files /tmp);
+Calling system(rsync -e 'ssh ' -akz --yes --invoke @dev:'/tmp/drush-sandbox/web/%files' /tmp);

Looks like I dropped a var; will look at it later.

greg.1.anderson’s picture

Issue tags: +Release blocker

Any objection to back-porting #2 + #4 to 7.x-5.x dev? Still working on tests, but Jonhattan wants to role a 5.9 release. Remove 'Release blocker' tag if you don't want it to go in.

greg.1.anderson’s picture

Title: Manage environment variables used in Drush script in tests and backend invoke » Manage environment variables used in Drush script in tests
Status: Needs review » Patch (to be ported)

Committed 5ae596c, which allows tests to specify environment variables, and adds a test of the drush script using the PHP_OPTIONS environment variable. Environment variable handling in backend invoke and aliases can be done in a separate issue, as needed.

Is this (#2, #4, #10) desired for 7.x-5.x?

moshe weitzman’s picture

In that commit, we construct a variable $expected in the test but never use it. Not a big deal and can be backported with this blemish if needed.

greg.1.anderson’s picture

I noted that mistake in #7, but forgot to fix it. I'll remove the unused line and backport.

greg.1.anderson’s picture

Version: 8.x-6.x-dev » 7.x-5.x-dev
Status: Patch (to be ported) » Fixed

Backported to 7.x-5.x.

Automatically closed -- issue fixed for 2 weeks with no activity.