When attempting to run drush ": No such file or directory" 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" &amp;&amp; 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 &gt; /dev/null 2&gt;&amp;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")


wut

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
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 &lt;USERNAME&gt; 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:

SHELL=/bin/sh

to

SHELL=/bin/bash

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