0

I had a working drush 5.6 (manually installed) on OSX (Yosemite) and decided I wanted to upgrade to the latest drush 7 version. I ended up with version 6.0-dev.

I followed the installation isntructions and decided to use homebrew to install composer and drush. So far so good, but the thing is, I can't seem to get to the latest "master" dev version: I'm stuck on 6.0-dev.

I tried different ways like:

brew install --HEAD drush
brew switch drush HEAD

and:

composer global require drush/drush:dev-master
composer global update

My composer.json looks like this:

{
    "require": {
        "drush/drush": "dev-master"
    }
}

which drush:

/usr/local/bin/drush

drush status:

 PHP executable        :  /usr/bin/php                             
 PHP configuration     :                                           
 PHP OS                :  Darwin                                   
 Drush version         :  6.0-dev                                  
 Drush configuration   :                                           
 Drush alias files     :  /Users/albert/.drush/aliases.drushrc.php 

Any ideas?

  • 1
    Package management always feels a bit unnecessary for Drush, the simplest way to install (in my experience) is git clone https://github.com/drush-ops/drush.git /usr/local/share/drush; cd /usr/local/share/drush; composer install; ln -s /usr/local/share/drush/drush /usr/local/bin/drush. – Clive Nov 13 '14 at 11:21
  • Oh, and the result of which drush is wrong if you've installed via Composer. The correct path would be somewhere in ~/.composer/ (or wherever you have composer install to globally). You've probably installed via brew, that didn't work, haven't removed the brew version, then installed via composer, and forgotten to add composer's global path to your system path. So it's still picking up brew's version in /usr/local/bin. brew remove drush before trying the composer method, then add that path to system path, and you should be good – Clive Nov 13 '14 at 11:25
  • Thanks, your first approach seems to work like a charm! Still a bit confused what is wrong in my setup. Had probably something do with the old version.. So I deleted /usr/local/bin/drush before creating the new symlink. – askibinski Nov 13 '14 at 11:27
  • 1
    If you have multiple Drush executables in your $PATH, you need to make sure that the one you want to use ($/.composer/vendor/bin) comes first. To do this, set your $PATH in .bashrc somewhere near the top, before the line [ -z "$PS1" ] && return. Removing all of the other installations of Drush on the system also works, of course. – greg_1_anderson Nov 13 '14 at 16:52
1

You should add to your ~/.bashrc file the additional PATH, e.g.:

# Add a Composer's global bin directory if exists.
which composer >/dev/null && export PATH="$HOME/.composer/vendor/bin:$PATH"

It should come first before your other drush. See my full .bashrc for details (bash4 syntax).


Alternatively install drush by specifying COMPOSER_BIN_DIR, like:

COMPOSER_BIN_DIR=/usr/local/bin composer global require drush/drush:dev-master

Assuming that /usr/local/bin is already in your PATH.

  • kenorb, your .bashrc has an error. You erroneously changed [ -z "$PS1" ] && return to not return; this might cause problems when using this .bashrc in a non-interactive shell. You should put the $PS1 check back the way it was, and then move the code that sets the $PATH, and anything else needed in non-interactive shells, to someplace above this line. – greg_1_anderson Nov 13 '14 at 16:50
  • @greg_1_anderson Thanks, I'll have a look into it and re-test. – kenorb Nov 13 '14 at 16:53
  • @greg_1_anderson I think it should work fine for bash4, otherwise there is a possible syntax error with older versions. If that's you mean. Otherwise I can't find [ -z "$PS1" ] && return code in that file. Which line it's? – kenorb Nov 13 '14 at 16:56
  • 1
    You have the comment line # Determine within a startup script whether Bash is running interactively or not. unchanged from the Debian original, but the code that follows you changed to if [ ! -z "$PS1" ]; then echo ".bashrc loaded." fi. You should put that back to [ -z "$PS1" ] && return, and move only the needed parts (e.g. setting $PATH) above that line. – greg_1_anderson Nov 13 '14 at 18:25
  • 1
    @greg_1_anderson Thanks, I did that. I also think to move composer PATH above that condition, otherwise non-composer drush would be used by default when invoking non-interactive commands on remotes. – kenorb Nov 13 '14 at 18:41
0

Upgrading to Drush 7

  • Remove old Drush : brew uninstall drush.
  • Install Composer : curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
  • Get drush from homebrew : brew install --HEAD drush
  • After that command has run, check the drush version : brew info drush
  • If it's still on 6.x (which it shouldn't be), check to the HEAD version by running : brew switch drush HEAD
  • Composer Install : cd /usr/local/Cellar/drush/HEAD/libexec && composer install
  • Check your work : drush cc drush ; drush --version ;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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