When I use a drush command to do something on a remote machine, I get the following message:
bash: drush: command not found
What's the problem?
When I use a drush command to do something on a remote machine, I get the following message:
bash: drush: command not found
What's the problem?
This message is from the remote machine complaining that it didn't understand where to find the drush
executable, not Drush complaining that it can't find the (sub)command you may be trying to give it, even though the punctuation suggests the latter. (If bash:
means Bash is passing you a message, then drush:
should mean the same thing--if there's any consistency. But actually it is intended to mean drush:
is the subject of the message, not the source of the message passed through bash:
to you. It would be clearer if the second :
were removed.)
Drush logs into your remote machine over ssh, but it's not a normal interactive login, so it doesn't source the .bash_profile. It does, however, source the .bashrc file.
Add the drush path (not including drush itself, just including the directory containing drush) to the PATH variable in your remote .bashrc and all should be well. For instance, that may look like this:
PATH=$PATH:/usr/local/zend/bin
[ -z "$PS1" ] && return
. Some platforms use this to bail out if running in non-interactive mode. Ubuntu, for example, puts this in your initial .bashrc. If you set your PATH, you need to make sure that you set it before any conditional such as this one that may force an early exit.
Commented
Oct 8, 2012 at 5:58
.bashrc
before the line # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac
on Ubuntu 14.04
Commented
Jul 24, 2014 at 19:56
zshenv
file (without a leading dot) with my desired export paths inside /etc (not my home directory).