Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
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,
Colin
Comments
Comment #1
greg.1.anderson CreditAttribution: greg.1.anderson commentedLooks 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.)Comment #2
cduwe CreditAttribution: cduwe commentedThanks 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?
Thanks,
Colin
Comment #3
greg.1.anderson CreditAttribution: greg.1.anderson commentedRun
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.Comment #4
greg.1.anderson CreditAttribution: greg.1.anderson commentedAlso, if setting the $PATH is too frustrating, you can always tell drush where your drush executable is located in your site alias:
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.
Comment #6
mollyavalon CreditAttribution: mollyavalon commentedI 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.
Comment #7
ssoulless CreditAttribution: ssoulless commentedHello 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 =(
Comment #8
helmo CreditAttribution: helmo commented[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.