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
Comments
Comment #1
greg.1.anderson commentedThere's an issue in the queue here about that; search for open_basedir and you should find it.
Comment #2
babycourageous commentedThanks Greg,
I will take a look at that and post my findings.
cheers
Comment #3
greg.1.anderson commentedHere you go: #509506: Drush users should turn of open_basedir in their drush-specific php.ini file
Comment #4
jonhattanIt 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...
Comment #5
mkoistinen commentedI 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:
Directly after the lines:
$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
jonhattanand the Drush team!Comment #6
greg.1.anderson commentedEditing 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.
Comment #7
mkoistinen commentedI 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?
Comment #8
greg.1.anderson commentedIt is normal if you forget the
<?phptag at the beginning of the file. :) Fix that, then try drush_set_context in your drushrc.php file again.Comment #9
mkoistinen commentedI 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.
Comment #10
greg.1.anderson commentedWhat 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.
Comment #11
mkoistinen commentedOK, 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.
Comment #12
greg.1.anderson commentedI 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").
Comment #13
jonhattanGreg 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:
The other problem @mkoistinen has is that it seems impossible to unset open_basedir in a custom drush.ini.
Comment #14
jonhattanComment #15
greg.1.anderson commentedOh 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?
Comment #16
jonhattanAttached 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
Comment #17
greg.1.anderson commentedLooks 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.
Comment #18
mkoistinen commentedOK, starting from a non-modified version of drush...
"Out of the box", when running it, I get
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:
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?
Comment #19
greg.1.anderson commentedCopy 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.
Comment #20
mkoistinen commentedI 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.
Comment #21
jonhattan@mkoistinen you needed to apply the patch, did you?
I'll commit this now so you can also use latest HEAD from cvs.
Comment #22
jonhattancommitted #16.
Moving to postponed to wait for @mkoistinen confirmation.
Comment #23
greg.1.anderson commentedSince this has been committed, let's just mark it 'fixed' and let the OP re-open if there are further problems.
Comment #24
mkoistinen commentedSorry 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:
I'm afraid that unless I modify line 470 of includes/environment.inc, I still get an error:
Otherwise, it is working fine.
Comment #26
chrisjlee commented@25 Is this fix included in the latest 4.2 version of drush?
Comment #27
greg.1.anderson commentedYes.
Comment #28
jessicakoh commented@mkoistinen Are you able to solve the above error? Mind sharing how did you do it?
I am Drush v5.9
Comment #29
ErikU commentedBrilliant!! I've been searching like crazy for a fix. Thanks a ton @jonhattan