I've been bashing my head against the wall all day trying to figure out why Drush has suddenly stopped working.

I've re-installed via composer, tried different versions, always the same error.

If I type which drush I get /home/user/.composer/vendor/bin/drush which is correct.

If I type sh -vx drush in an attempt to debug what's happening with the script, I get the following output:

#!/usr/bin/env sh
# This script is a simple wrapper that will run Drush with the most appropriate
# php executable it can find.
# Solaris users: Add /usr/xpg4/bin to the head of your PATH

: not found/.composer/vendor/bin/drush: 8: /home/user/.composer/vendor/bin/drush: 
# Get the absolute path of this executable
SELF_DIRNAME="`dirname -- "$0"`"
+ dirname -- /home/user/.composer/vendor/bin/drush
+ SELF_DIRNAME=/home/user/.composer/vendor/bin
SELF_PATH="`cd -P -- "$SELF_DIRNAME" && pwd -P`/`basename -- "$0"`"
+ cd -P -- /home/user/.composer/vendor/bin
/home/user/.composer/vendor/bin/drush: 1: cd: can't cd to /home/user/.composer/vendor/bin
+ basename -- /home/user/.composer/vendor/bin/drush
+ SELF_PATH=/drush

: not found/.composer/vendor/bin/drush: 12: /home/user/.composer/vendor/bin/drush: 
# Decide if we are running a Unix shell on Windows
if `which uname > /dev/null 2>&1`; then
  case "`uname -a`" in
/home/user/.composer/vendor/bin/drush: 15: /home/user/.composer/vendor/bin/drush: Syntax error: word unexpected (expecting "in")


Ok, maybe something wonky is returned with uname -a? The response from my server is:

Linux servername 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

There are no directory permission issues... everything is owned by the user. I'm at a complete loss. I've tried drush 5, 6, and 7 - same sort of error in each.

The server is running Ubuntu 12.04.2 LTS


7 Answers 7


I was getting this same error when running drush commands on a remote computer via a drush alias. I could run the same drush commands on the remote system directly with no problems but when I would try to run them via a drush alias (@remotesystem) I would get this error.

I found that the user on the remote systems default shell was sh and not bash. Because the bash configuration file ~/.bashrc contains the line that adds the location of drush to the path the sh shell was not able to find drush as ~/.bashrc will not be sourced by the sh shell only by bash.

The drush installation instructions on docs.drush.org state:

Now add Drush to your system path by placing export PATH="$HOME/.composer/vendor/bin:$PATH" into your ~/.bash_profile (Mac OS users) or into your ~/.bashrc (Linux users).

You can check what your current shell is set to by running:

export |grep SHELL

This will print a line with your current shell in it like this:

declare -x SHELL="/bin/bash"

On Ubuntu the default shell is sh but the default user shell is bash. This happened on a Ubuntu Server install (no GUI).

To fix this change your default shell to bash.

For current users run the following to change the default shell:

sudo -u <USERNAME> chsh -s /bin/bash

For future users, if you use useradd, edit the /etc/default/useradd skeleton file (don't forget to make a backup though). Change the line:




This will set bash as the shell for new users that are created.

  • That's crazy. If the script has #!/usr/bin/env sh then it needs to be sh-compatible. Overwriting SHELL in the middle of a session is completely pointless anyway.
    – tripleee
    Oct 14, 2016 at 6:50
  • @tripleee The script is sh compatible. The problem is that the sh shell in a not-interactive login does not have drush in its path, but the bash shell does have drush in its path. Another solution would be to configure the path for sh shell so it can find drush during a non-interactive session. I run other bash commands non-interactive on servers and prefer to use the bash shell. That is why I do it this way, ie. change the shell for non-interactive sessions. Oct 15, 2016 at 13:02
  • You are still confused. The PATH variable for sh is set in .profile for login shells, and usually inherited by non-login shells. However, if your login does not involve a login shell (as is the case with some windowing systems) you will have to initialize the `PATH´ separately ... or just use a hard-coded path to the actual location of the command you want to run.
    – tripleee
    Oct 16, 2016 at 10:59
  • This solution is not acceptable. It cannot be used in a shared environment or in a situation where people have no permission to change the default shell. I have posted a solution that involves using the %drush-script in the path-aliases.
    – asiby
    Aug 31, 2019 at 18:10

My issue was caused by the .bashrc not being fully processed by non interactive shells https://stackoverflow.com/a/941995/980921


Drush cannot be found due to $PATH not providing the path to where Drush is, so the error env: drush: No such file or directory results. In the accepted answer that's due to a different shell being used, but there are other possible causes and solutions in addition to that.

In running Drush on a remote site via Drush aliases, for example, there might be problems with SSH and the non-interactive non-login nature of that shell connection... so if your $PATH is defined ~/.bash_profile and it doesn't get loaded, moving the $PATH definition to ~/.bashrc can be a solution in that case.

  • This worked. Thanks. I am using a shared environment where changing the default shell is out of the question. Also, I have no access to anything outside my $HOME directory. The solution suggested by @alec worked right away.
    – asiby
    Aug 31, 2019 at 17:52
  • However, I have found a solution that might be better.
    – asiby
    Aug 31, 2019 at 18:07

To solve this specific issue that I was also having, all you need to do is to provide a drush-aliases configuration as shown in the following example ...

$aliases['prod'] = array (
  'uri' => '...',
  'root' => '...',
  'remote-host' => '...',
  'remote-user' => '...',
  'os' => '...',
  'path-aliases' => array(
    '%drush-script' => '/home/user/.composer/vendor/bin/drush', // <-- This is what you need

After that, you might need to clear the cache using drush cc drush and try again.

This worked for me.


If you are confident that the path to Drush is correct, Try giving execute permission to drush binary.

chmod a+x drush
  • Yep - the path is correct, and Drush is executable.
    – jmking
    Jan 30, 2014 at 16:35

May be it's caused by dos line endings. you can fix it by editing this file drush in vim and executing ":set ff=unix" with reference from your question on github

If the above solution dose not works then try this:

sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

Additionally, you may need to adjust your php.ini settings before you can use drush successfully. here is the reference


In my case I removed drush crom vendor directory, and it helped.

In my PATH there were many instances of drush.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.