Summary :

Can't get drush remote alias commands to work on Bluehost account
I get error env: drush: No such file or directory (see very bottom of this post)

===================================================
I have a drupal 7 site hosted on Bluehost and want to start managing it with drush.

I've installed composer and drush on my Linux computer at home and composer and drush on my Bluehost shared host account.
(drush was installed using composer on both)

All drush commands work fine on my home computer.

I've setup a drush remote site alias to access my drupal 7 site (on Bluehost).

To verify that the alias is working and ssh is working I'm able to ssh into my site using the remote site alias

(In the outputs below I've replaced my actual site user name with 'user' and site name with 'mysite')

From my home computer :

[raynaldmo@localhost]$ drush @mysite.prod ssh         <==== drush remote site alias
user@mysite.com [~/public_html]#

Here is the ouput of some commands from my site account

user@mysite.com [~/public_html]# pwd
/home3/user/public_html

user@mysite.com [~/public_html]# ls
./             cron.php                  index.php           LICENSE.txt      README.txt  UPGRADE.txt
../            favicon.ico               INSTALL.mysql.txt   MAINTAINERS.txt  robots.txt  web.config
authorize.php  .gitignore                INSTALL.pgsql.txt   misc/            scripts/    xmlrpc.php
cgi-bin/       .htaccess                 install.php         modules/         sites/
CHANGELOG.txt  .htaccess.bak.1450846585  INSTALL.sqlite.txt  php.ini          themes/
COPYRIGHT.txt  includes/                 INSTALL.txt         profiles/        update.php
user@mysite.com [~/public_html]# hostname
box806.bluehost.com

user@mysite.com [~/public_html]# which php
/usr/php/54/usr/bin/php

user@mysite.com [~/public_html]# which drush
/home3/user/drush7/vendor/bin/drush

user@mysite.com [~/public_html]# echo $PATH
/usr/local/jdk/bin:/usr/lib64/qt-3.3/bin:/home3/user/perl5/bin:/usr/local/jdk/bin:/ramdisk/php/54/bin:/usr/php/54/usr/bin:/usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin:/home3/user/bin:/home3/user/drush7/vendor/bin

Drush works fine on my Bluehost site account

user@mysite.com [~/public_html]# drush core-status
 Drupal version                  :  7.24                                                
 Site URI                        :  http://default                                      
 Database driver                 :  mysql                                               
 Database hostname               :  localhost                                           
 Database port                   :                                                      
 Database username               :  user_admin                                      
 Database name                   :  user_db                                         
 Drupal bootstrap                :  Successful                                          
 Drupal user                     :                                                      
 Default theme                   :  zircon                                              
 Administration theme            :  seven                                               
 PHP executable                  :  /usr/php/54/usr/bin/php-cli                         
 PHP configuration               :  /usr/php/54/etc/php.ini                             
 PHP OS                          :  Linux                                               
 Drush script                    :  /home3/user/drush7/vendor/drush/drush/drush.php 
 Drush version                   :  7.1.0                                               
 Drush temp directory            :  /tmp                                                
 Drush configuration             :                                                      
 Drush alias files               :                                                      
 Install profile                 :  standard                                            
 Drupal root                     :  /home3/user/public_html                         
 Site path                       :  sites/default                                       
 File directory path             :  sites/default/files                                 
 Private file directory path     :  sites/default/files/private                         
 Temporary file directory path   :  /tmp                       

The problem is when I try to execute a drush command remotely on my site from my home computer, I
get the error "env: drush: No such file or directory"

From my home computer :

[raynaldmo@localhost public_html]$ drush -vd @mysite.prod core-status
Starting Drush preflight. [0.01 sec, 1.29 MB]                                                               [preflight]
Cache HIT cid: 7.1.0-commandfiles-0-757bad0a33840a810dfd6a2b4fe1234f [0.01 sec, 1.32 MB]                        [debug]
Loaded alias @mysite.prod from file /home/raynaldmo/.drush/mysite.aliases.drushrc.php [0.14 sec,   [notice]
3.52 MB]
Begin redispatch via drush_invoke_process(). [0.15 sec, 3.53 MB]                                               [notice]
Backend invoke: ssh -o PasswordAuthentication=no user@mysite.com 'env COLUMNS=119 drush            [command]
--verbose --debug --uri=http://mysite.com --root=/home3/user/public_html  core-status 2>&1' 2>&1
[0.15 sec, 3.53 MB]
Calling proc_open(ssh -o PasswordAuthentication=no user@mysite.com 'env COLUMNS=119 drush  --verbose --debug --uri=http://mysite.com --root=/home3/user/public_html  core-status 2>&1' 2>&1);

env: drush: No such file or directory   <==== Error
End redispatch via drush_invoke_process(). [3.06 sec, 3.53 MB]                                                 [notice]

Comments

rolfmeijer’s picture

I was wondering if you found some solution for this, because I have the exact same problem and can’t find what’s wrong. In my case both drush versions (local and on the remote) are 8.0.1.

If I find something, I will post it here.

rolfmeijer’s picture

I found something on http://stackoverflow.com/questions/940533/how-do-i-set-path-such-that-ss... and http://drupal.stackexchange.com/questions/101601/when-attempting-to-run-...

I added the PATH (PATH="/usr/local/vendor/bin:$PATH") to my .bashrc on the remote, before anything else. In my case it started with this:

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

I’m not a bash wizard, but when I added my PATH to drush before these lines, my drush alias worked. But I might have to check with our server admin to get his permission for this :-).

Drupalized by Jason’s picture

I am also having this issue...

Drush works fine on local mac, Drush works fine when I ssh into my bluehost account, can not get the live site alias to work from my local mac... getting the same env: drush: No such file or directory...

I have tried adding the PATH as rolfmeijer suggested however that didn't resolve the issue for me. Anyone else have any thoughts on this? I would love to get this working...

Ericmaster’s picture

In my case, explicitly specifying the '%drush_script' path (path in the remote server) in the corresponding alias definition fixed the issue for me.

See https://github.com/drush-ops/drush/blob/master/examples/example.aliases....

Drupalized by Jason’s picture

Adding the %drush_script did get rid of the env: drush: No such file or directory that I was getting but now i'm getting a new error which is:

bash: /Applications/MAMP/bin/php/php5.6.6/bin/php: No such file or directory

So it seems that it's looking for the php version i'm using on my Mac? I tried adding 'php' => 'path/to/server/php', to my alias file but that didn't work either...

Anyone have any suggestions? I would really love to get this going so I didn't have to do the archive dump and restore each time I want to sync up the sites.

Ericmaster’s picture

How are you setting up the drush alias and making the drush call? Make sure to add that only to the specific drush alias you are using to connect remotely, 'remote-host' and 'remote-user' should be set as well.

Drupalized by Jason’s picture

Drush works fine on my mac, also works fine if I ssh to bluehost from Terminal and run drush status there.

On the mac in my aliases.drush.rc.php file I have my local dev alias...

//dev
$aliases['dbj'] = array(
'uri' => 'dbj',
'root' => '/Applications/MAMP/htdocs/dbj',
);

And my Live site alias... (username actually filled in though)

//live
$aliases['dbjlive'] = array (
'uri' => 'http://drupalizedbyjason.com',
'root' => '/home1/drupaliz/public_html',
'remote-host' => 'drupalizedbyjason.com',
'remote-user' => 'USER',
'os' => 'Linux',
'path-aliases' => array (
'%drush' => '/home1/drupaliz/.composer/vendor/drush',
'%drush-script' => '/home1/drupaliz/.composer/vendor/drush/drush/drush.php',
),
);

Then in Terminal I run drush @dbjlive status and was getting the original error until I added the %drush-script as you suggested and now just get bash: /Applications/MAMP/bin/php/php5.6.6/bin/php: No such file or directory...

dimaboychev’s picture

Same exact issue (using Linux).
--EDIT:

The issue in my case was that for '%drush-script' path I was specifying my local machines drush.php file, which obviously is wrong because on your remote machine it can and most likely will be different.
So I SSH into remote machine. Ran "drush status" there and saw the correct "Drush script" path. Then everything worked.
Hope I helped someone.

raffi’s picture

Your solution worked perfectly

Ericmaster’s picture

Sorry I wasn't able to respond lately, were you able to fix the issue? Maybe try setting the 'php' property as well with the correct path to php.

Drupalized by Jason’s picture

Still a no go... I added 'php' => '/usr/php/54/usr/bin/php', to the remote alias and now if I run a drush @dbjlive status I get Content-type: text/html...

paulvandenburg’s picture

Thanks this was indeed exactly what I'm looking for.

However your link is broken. Here are updated links for Drush 8 + 9:

Drush 8: https://github.com/drush-ops/drush/blob/8.x/examples/example.aliases.dru...

Drush 9: https://github.com/drush-ops/drush/blob/9.5.x/examples/example.site.yml

Drupalized by Jason’s picture

Still a no go... I added 'php' => '/usr/php/54/usr/bin/php', to the remote alias and now if I run a drush @dbjlive status I get Content-type: text/html...

justinlevi’s picture

For me all I needed to add the following line to my .bashrc

export PATH=$HOME/bin:$PATH

---

Apparently my .bash_profile was not getting loaded during the drush ssh connection. You can troubleshoot by doing adding `--debug` to your drush command like:

$ drush @youralias status --debug

This will give you the full ssh command that is run which you can then copy/paste directly into your terminal to learn more what might be going on. In my case I ran the following command to verify that the PATH that my ssh connection was seeing was different than the PATH I was seeing when I ssh'd into my server directly.

$ ssh -o PasswordAuthentication=no username@remote-host.com 'echo $PATH'

stephenplatz’s picture

This helped, thanks for saving me some time justinlevi!

stevieegee’s picture

I had the exact same problem, which was solved by the following,

$aliases['com'] = array(
 ... STANDARD STUFF HERE ...
  'ssh-options' => '-o PasswordAuthentication=no -i /Users/stevieegee/.ssh/id_rsa',
  'path-aliases' => array(
    '%dump-dir' => '/tmp',
    '%files' => $remote_site . 'PATH TO FILES',
    '%drush-script' => '/home/admin/.config/composer/vendor/drush/drush/drush.php',
  ),
  'php' => '/usr/bin/php',
  'php-options' => '-d error_reporting="E_ALL^E_DEPRECATED"',
);
jarco’s picture

This is indeed a nice workaround. It worked for me.

Thanks

raffi’s picture

dimaboychev Your solution worked perfectly... 100+