I'd really appreciate it if anyone has any suggestions here. I have the following site alias defined:

$aliases['stage'] = array(
    'uri' => 'default',
    'root' => 'html/drupal',
    'remote-host' => 'mysite.com',
    'remote-user' => 'user',

But when I execute "drush @stage" (or status, etc) it returns with:

The command could not be executed successfully (returned: bash: drush: command not [error]
found, code: 127)

I can log in via SSH from my local machine terminal to the remote machine console w/ out a password and execute "drush" or any other command. Changing the "remote-host" value gives a "couldn't log in" error so I'm fairly certain I'm logging in OK.

Thanks In Advance,


greg.1.anderson’s picture

Status:Active» Fixed

Looks like a $PATH problem. The bash files sourced can vary based on the method of access and the distribution of Linux used. For example, on Ubuntu, .bash_profile is sourced when you log in to a shell, but .bashrc is sourced if you are executing a remote command via ssh. Make sure that you set $PATH in a location that will affect the shell you are using.

Also, I would recommend that you change 'uri' to 'mysite.com', and 'remote-host' to whatever hostname -f is printing out. (If hostname -f is printing out just the machine name, then you do have to add the domain part to your alias record, of course.)

cduwe’s picture

Thanks for the help. Can you clarify one thing. I think I'm using the same method of access. I'm on my Mac's terminal at
My-Macbook-Pro:sitename username$
Then I enter:
SSH username@sitename.com
and I get a new prompt:
[servername ~]$
at that prompt I can execute drush on that server.
How is Drush connecting? Is it not SSH?


greg.1.anderson’s picture

Run drush @stage status --debug and you will see the exact ssh command that drush uses. The difference is that the ssh command you show in #2 spawns a login shell, and the ssh command that drush uses, with a -c, is not a login shell. Define the path to drush in your .bashrc and see if that does not solve your problem.

greg.1.anderson’s picture

Also, if setting the $PATH is too frustrating, you can always tell drush where your drush executable is located in your site alias:

$aliases['stage'] = array(
    'uri' => 'mysite.com',
    'root' => '/home/username/html/drupal',
    'remote-host' => 'mysite.com',
    'remote-user' => 'user',
    'path-aliases' => array(
      '%drush-script' => '/path/to/drush/drush',

I also noticed that you made 'root' a relative path; it is a better idea to always make 'root' a full path, just to avoid any ambiguities with the cwd in a non-login shell.

Status:Fixed» Closed (fixed)

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

mollyavalon’s picture

I know this is an old thread, but #4 fixed a problem I had on all my shared hosting sites and I am deeply deeply grateful. I wish I could think of a good place to put it or a way to highlight it for others.

ssoulless’s picture

Issue summary:View changes
Status:Closed (fixed)» Active

Hello I followed #4 but I get this error

Error in argument 1, char 2: option not found r
/chroot/drush/drush: line 125: [: too many arguments
Content-type: text/html

Please help me =(

helmo’s picture

Status:Active» Fixed

[Stock response from Dreditor templates and macros.]

This issue was marked closed (won't fix) because Drush has moved to Github.
If this feature is still desired, you may copy it to our Github project. For best results, create a Pull Request that has been updated for the master branch. Post a link here to the PR, and please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.

Status:Fixed» Closed (fixed)

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