I have been using Drush on my local computer but am getting ready to launch a site and wated to be able to continue using Drush remotely. After some digging I found the following instructions for installing on a Media Temple Grid Server (shared environment)
http://ignoredbydinosaurs.com/2010/07/installing-drush-media-temple-grid...

I followed the instructions there, SSH to my server, run the drush command and receive the following heinous warnings and error :

file_exists(): open_basedir restriction in effect.                   [warning]
File(/etc/drush/drushrc.php) is not within the allowed path(s):
(/nfs:/tmp:/usr/local:/etc/apache2/gs-bin) context.inc:141

is_dir(): open_basedir restriction in effect.                        [warning]
File(/usr/share/drush/commands) is not within the allowed path(s):
(/nfs:/tmp:/usr/local:/etc/apache2/gs-bin) command.inc:497
Execute a drush command. Run `drush help [command]` to view command-specific
help.

Examples:

Fatal error: Class 'Console_Table' not found in /nfs/c06/h02/mnt/90837/users/.home/bin/drush/includes/drush.inc on line 780
Drush command could not be completed.                                [error]

I am totally at a loss for why this is (specifically why drush is looking for files in etc/drush and usr/share/drush directories which don't exist and aren't used locally)

If more info is needed I can provide.

Thanks

CommentFileSizeAuthor
#16 drush-949708.patch853 bytesjonhattan
#11 drush-output.txt5.33 KBmkoistinen

Comments

greg.1.anderson’s picture

There's an issue in the queue here about that; search for open_basedir and you should find it.

babycourageous’s picture

Thanks Greg,
I will take a look at that and post my findings.
cheers

jonhattan’s picture

Status: Active » Postponed (maintainer needs more info)

It seems open_basedir restriction are just harmful warnings. The problem is below: Console_Table

@babycourageous first time drush runs it needs to download an external library that provides Console_Table. It is downloaded to includes/table.inc. It seems drush was unable to download table.inc, or it is empty. As a last resort you an get the file from
http://svn.php.net/viewvc/pear/packages/Console_Table/trunk/Table.php?re...

mkoistinen’s picture

Version: All-versions-3.3 » All-versions-4.1

I would just like to report, that with the brilliant help of jonhattan, I've been able to get Drush 4.1 working on my MediaTemple (mt) GridServer (gs).

NOTE: below refers to the drush directory where ever you've installed it. In my case, I've installed it in ~/bin/drush, so on my server, this path was /home/XXXXX/users/.home/bin/drush. Yours should be similar.

The things we did to make it work were:

  1. Force valid contexts for SHARE_PREFIX and ETC_PREFIX:
    • Edit /drush.php to add:
      drush_set_context('SHARE_PREFIX', '<drush_install>');
      drush_set_context('ETC_PREFIX', '<drush_install>');
      

      Directly after the lines:

      drush_set_context('argc', $GLOBALS['argc']);
      drush_set_context('argv', $GLOBALS['argv']);
      
  2. Disable the environment check for open_basedir:
    • Edit line ~470 of /includes/environment.inc to change:

      $ini_checks = array('safe_mode' => '', 'open_basedir' => '', 'disable_functions' => array('exec', 'system'), 'disable_classes' => '');
      to:
      $ini_checks = array('safe_mode' => '', 'disable_functions' => array('exec', 'system'), 'disable_classes' => '');

I have not hit any roadblocks so far with this drush install, but I've not used this too extensively yet, but I have been able to use this to clear-cache, pm-download and pm-install, status, and other basic stuff, which is already a huge help.

Big thanks to jonhattan and the Drush team!

greg.1.anderson’s picture

Title: Remote installation errors (on Media Temple Grid Server) » Need a sanctioned way to set SHARE_PREFIX, ETC_PREFIX, and also to disable ini_checks that the user wants to skip
Category: support » feature
Status: Postponed (maintainer needs more info) » Active

Editing drush.php is not a good idea. Presumably, those calls to drush_set_context could just be placed in your drushrc.php file, and it would work fine. However, I have to wonder why does the code use drush_get_context instead of drush_get_option? Performance? Seems that maybe there should be a drush_set_context('SHARE_PREFIX', drush_get_option('share-prefix', '/usr')); somewhere during bootstrap (in set global options, maybe?).

Side note: I would recommend against making SHARE_PREFIX and ETC_PREFIX == ; make some other folder that you have write access to, and point these variables there, so things don't get all mixed in with drush core.

Regarding the ini_checks, these are useful and helpful most of the time for most users; however, I think we should have some way for someone to specify in their drushrc.php that certain ini modes that they have set are "okay" with them and should be skipped when drush does its ini checks.

mkoistinen’s picture

I agree that this should be more sanctioned, and I'm not crazy about 'hacking core' here, but this is what it took. We tried adding the drush_set_context(...) to .drush/drushrc.php, but they didn't work. Also, everything that is in drushrc.php prints to the screen every time you run drush. Is this normal?

greg.1.anderson’s picture

everything that is in drushrc.php prints to the screen every time you run drush. Is this normal?

It is normal if you forget the <?php tag at the beginning of the file. :) Fix that, then try drush_set_context in your drushrc.php file again.

mkoistinen’s picture

I did shortly after I wrote that (it got me thinking). Anyway, without any changes, drush reported 1 error and 2 warnings. The change in the environment.php file eliminated the error. After setting context in the drushrc.php (WITH the PHP tags), it remained broken with 1 warnings. Setting the context in drush/drush.php, left no warnings.

greg.1.anderson’s picture

Status: Active » Postponed (maintainer needs more info)

What do you mean "broken with 1 warning"? Usually, warnings do not interfere with the operation of the current command. Could you provide more info? Maybe drush is referencing the environment variables before drushrc.php is being loaded.

mkoistinen’s picture

StatusFileSize
new5.33 KB

OK, so I guess 'Broke with warnings' wasn't the best description =). I've attached the output for both the drush_set_context() lines in the drushrc.php and again in the drush.php file. Have a look. I hope this is useful.

greg.1.anderson’s picture

Status: Postponed (maintainer needs more info) » Active

I think we decided a while back that we were not going to support open_basedir in drush. I don't quite remember; I'd have to search old issues.

By default, drush will look at 'SHARE_PREFIX' and 'ETC_PREFIX' to decide where to load drushrc.php files. In the case you show above, nothing is 'broken'; you just get spurious warnings as drush looks around for config files.

I'm not so keen on fixing this myself; I'm sort of wavering between 'patches welcome' and 'behaves correctly' ("works as implemented").

jonhattan’s picture

Status: Active » Postponed (maintainer needs more info)

Greg you're right in #10. The context is needed for the configuration files to be loaded properly. This is why I suggested to hack core :) just to confirm an issue and a fix.

Now that I look into includes/environment.inc It seems we have already the piece to fix this: drushrc.php in drush base directory:

  // Load a drushrc.php file in the drush.php's directory.
  drush_load_config('drush');

  // Load a drushrc.php file in the $ETC_PREFIX/etc/drush directory.
  drush_load_config('system');

  // Load a drushrc.php file at ~/.drushrc.php
  drush_load_config('user');

  // Load a drushrc.php file in the ~/.drush directory.
  drush_load_config('home.drush');

The other problem @mkoistinen has is that it seems impossible to unset open_basedir in a custom drush.ini.

jonhattan’s picture

Status: Postponed (maintainer needs more info) » Active
greg.1.anderson’s picture

Oh yeah, the ini_checks change I mention in #6 are worth doing.

Maybe we should change the order the the files are loaded (as shown in #13) so that 'system' is checked last. The problem with that is it might mess up configurations where people refer to and modify the global configuration settings in their personal drushrc.php files. Is that common enough to care about?

jonhattan’s picture

Title: Need a sanctioned way to set SHARE_PREFIX, ETC_PREFIX, and also to disable ini_checks that the user wants to skip » Check for php.ini/drush.ini in drush installation directory
Status: Active » Needs review
StatusFileSize
new853 bytes

Attached patch allows to use drush.ini in the drush install directory. The other day I asked @mkoistinen in IRC to proceed this way to neutralize open_basedir. Obviously didn't work and I did go wild with ETC_PREFIX.

Perhaps @mkoistinen can confirm he is able to unset open_basedir in MediaTemple so we don't need to change current drush restriction.
If so, we can bury ETC_PREFIX again and there's no issue but the undocumented requirement to set it at an early stage, in a drushrc.php placed in drush's folder.
Moving system config file after user defined ones to be more flexible on this point seems not appropiate to me. It will supress the option to do overrides, that is theorically very interesting in a multiuser server setup... It is not a very common usecase but we have already seen here that the need to set ETC_PREFIX is very rare enough :) --probably also in a server-wide setup.

ps. title change in the search for an issue

greg.1.anderson’s picture

Status: Needs review » Reviewed & tested by the community

Looks reasonable to me. Seems the existing location of $HOME/.drush should also work as well, but if #16 solves the OP's problem, then I'm in favor of it.

mkoistinen’s picture

OK, starting from a non-modified version of drush...

"Out of the box", when running it, I get

The following restricted PHP modes have non-empty values:            [error]
open_basedir. This configuration is incompatible with drush.  Please
check your configuration settings in
/usr/local/php-5.2.14-1/etc/php.ini or in your drush.ini file; see
examples/example.drush.ini for details.
file_exists(): open_basedir restriction in effect. File(/etc/drush/drushrc.php) is not within the allowed path(s):                            [warning]
(/nfs:/tmp:/usr/local:/etc/apache2/gs-bin) context.inc:139
is_dir(): open_basedir restriction in effect. File(/usr/share/drush/commands) is not within the allowed path(s):                              [warning]
(/nfs:/tmp:/usr/local:/etc/apache2/gs-bin) command.inc:855
Execute a drush command. Run `drush help [command]` to view command-specific help.  Run `drush topic` to read even more documentation.

Global options (see `drush topic` for the full list):
[ normal drush output follows ]

So, MediaTemple offer these instructions, which I have followed: http://wiki.mediatemple.net/w/GS:Allow_multiple_open_basedir_directories

I've installed the drush folder here /home/12345/users/.home/bin/
I've created another folder here: /home/12345/users/.home/tmp/etc
and here /home/12345/users/.home/tmp/share
The websites I host are all in /home/12345/domains/

I've created an .htaccess file inside the drush install directory (so .../bin/drush/.htaccess), readable by all which contains the line:
php_value open_basedir /home/12345/users/.home/tmp/:/home/12345/domains/

So far, no changes, same output as above.

I've also created a drushrc.php in the drush install directory with these lines:

<?php
drush_set_context('SHARE_PREFIX', '/home/12345/users/.home/tmp/share');
drush_set_context('ETC_PREFIX', '/home/12345/users/.home/tmp/etc');
?>

Now, I don't get the warnings, but I still get the error as shown above.

So, I've also created a drush.ini file from the example, and I have set:
open_basedir = "/home/12345/users/.home/tmp/:/home/12345/domains/"

Tried it both with and without quotes around the path, doesn't make a difference. Both issue the error as above.

To get rid of the error, I modified line 470 of the file /includes/environment.php to exclude a test for open_basedir.

Now I don't get any errors or warnings.

What have I missed?

greg.1.anderson’s picture

Copy examples/example.drush.ini to $HOME/.drush/drush.ini or /path/to/drush/drush.ini and edit it to suit. In particular, make sure that it contains the line:

open_basedir =

Then, open_basedir will not be set when running drush, but will be set when running php through the web server.

mkoistinen’s picture

I have set the drush.ini to include "open_basedir =" on an uncommented line.

It had no effect on the error when this file was in the /path/to/drush/ or ~/.drush/ directories.

jonhattan’s picture

@mkoistinen you needed to apply the patch, did you?

I'll commit this now so you can also use latest HEAD from cvs.

jonhattan’s picture

Version: All-versions-4.1 »
Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

committed #16.

Moving to postponed to wait for @mkoistinen confirmation.

greg.1.anderson’s picture

Status: Postponed (maintainer needs more info) » Fixed

Since this has been committed, let's just mark it 'fixed' and let the OP re-open if there are further problems.

mkoistinen’s picture

Sorry for my delay, folks.

I have applied the patch, and moved my drush.ini into the drush install directory. This drush.ini has the uncommented line:

open_basedir =

I'm afraid that unless I modify line 470 of includes/environment.inc, I still get an error:

The following restricted PHP modes have non-empty values:            [error]
open_basedir. This configuration is incompatible with drush....

Otherwise, it is working fine.

Status: Fixed » Closed (fixed)

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

chrisjlee’s picture

@25 Is this fix included in the latest 4.2 version of drush?

greg.1.anderson’s picture

Yes.

jessicakoh’s picture

Version: » All-versions-4.2
The following restricted PHP modes have non-empty values:            [error]
open_basedir. This configuration is incompatible with drush....

@mkoistinen Are you able to solve the above error? Mind sharing how did you do it?

I am Drush v5.9

ErikU’s picture

Brilliant!! I've been searching like crazy for a fix. Thanks a ton @jonhattan