Error sending Drush commands to remote host I have Drush 5.2 installed on my local dev system and my remote host, which has staging and production sites. I have aliases for all three sites, and am able to use rsync and sql-sync on both systems with no problems. 

From what I understand, I'm should also be able to issue commands to the remote system such as 

drush @stage vset preprocess_css 0


Whenever I try to do something like this, it fails. For instance, if I run drush -d @stage status, I get:

Bootstrap to phase 0. [0 sec, 3.7 MB]                                [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.01 sec, 3.93 MB] [bootstrap]
Loaded alias @stage from file /path/to/local/drupal/sites/all/drush/aliases.drushrc.php [0.01 sec, 3.94 MB]                          [notice]
Cache HIT cid: 5.2-commandfiles-0-c87dbef8e3e302e07ccdc024aee7fbbd [0.16 sec, 3.95 MB]                                                                      [debug]
Begin redispatch via invoke process [0.19 sec, 8.77 MB]                                                                                                    [notice]
Backend invoke: ssh -o PasswordAuthentication=no user@my.host.com 'drush  --invoke --debug                                                 [command]
--root=/path/to/remote/drupal/ --uri=http://stage.mysite.com --verbose status 2&gt;&amp;1' 2&gt;&amp;1 [0.23 sec, 8.8 MB]
executing ssh -o PasswordAuthentication=no user@my.host.com 'drush  --invoke --debug --root=/path/to/remote/drupal/      [notice]
--uri=http://stage.mysite.com --verbose status 2&gt;&amp;1' 2&gt;&amp;1 [0.23 sec, 8.8 MB]
Calling proc_open(ssh -o PasswordAuthentication=no user@my.host.com 'drush  --invoke --debug --root=/path/to/remote/drupal/ --uri=http://stage.mysite.com --verbose status 2&gt;&amp;1' 2&gt;&amp;1);
bash: drush: command not found
Invoke process is complete [1.34 sec, 8.79 MB]
In order for remote commands to work, you must make sure that drush is in your PATH.  This is often done by putting something like the following in a line that bash will source when it starts up:

export PATH=$PATH:$HOME/local/drupal/drush


A lot of folks put a line like this in their ~/.bashrc file, but note that on a lot of systems, this file begins with a line similar to the following:

[ -z "$PS1" ] &amp;&amp; return


This means that everything below the line above will only execute when bash is running interactively; if you put drush in your PATH after this point, you will be able to run drush when you log in to your remote machine, but not when you attempt to call drush remotely (e.g. via drush, as shown above).

There are many solutions to this problem.


Set your PATH before .bashrc bails out.
Make a symbolic link to your drush executable from a directory that is always in your PATH (e.g. sudo ln -s /path/to/drush /bin)
Set %drush-script as described in examples.aliases.drushrc.php.