When I first started learning Drupal, I remember the process of enabling and disabling modules on the Modules page took for-ev-er. My laptop was in serious danger of getting hurled across the room due to my frustration. Then I discovered drush, and I could download and enable modules with ease instead of pain and suffering. Of course there's a lot more you can do with drush than just download and enable modules; this is just one example.
I've been using Drush 6.x on my local machine for quite some time now. Poking around Drupal 8's UI and seeing what's new, I haven't missed drush too much...until it was time to test drive a new contributed module for Drupal 8. When I typed into my Terminal window drush dl page_manager
, I got quite the error message:
Drush 6.x only works with Drupal 6 or 7. If I wanted to use Drush on my Drupal 8 site, I would need to upgrade to Drush 7.x.
I followed the instructions in the error message (which I think means to say "Drush 6.1.0 does not support Drupal 8"), which tells me to see http://drupal.org/project/drush for more information. Once there, I find that the Drush project has been moved to GitHub.
So over to Drush's GitHub project page I go. There's a lot of documentation on this page, and this compatibility chart tells me which version of Drush I need for Drupal 8 (Drush 7.x) and which branch of the repo I'll need as well (master).
But before I dive into downloading the master branch, I scroll down to try and find upgrading instructions. Sure enough, there's an Install/Update section with instructions about how to upgrade Drush using Composer.
The first instruction is to "Install Composer globally (if needed)." I couldn't recall if I had or not (it seemed like maybe I had already), so I typed into my Terminal window: which composer
and it returned /usr/local/bin/composer
, which means, yes, I already had installed Composer globally. (If you need to install Composer, go here.)
Secondly, I wanted to make sure Composer's global bin directory is on the system PATH, so I copy/pasted the commands suggested in the Drush documentation:
sed -i '1i export PATH="$HOME/.composer/vendor/bin:$PATH"' $HOME/.bashrc
source $HOME/.bashrc
This ensures that when I type in composer commands, my shell knows which program to run, without needing the full path to the executable.
Now I'm ready to install Drush 7.x using Composer. I entered the following into my Terminal:
composer global require drush/drush:dev-master
Composer does its thing and downloads the correct branch from the drush git repository:
And, presto! I enter drush status
into Terminal and I can see that I'm now running Drush 7.0-dev and Drupal 8.0.0-dev.
drush dl page_manager
and drush en page_manager
inside my Drupal 8 site, I get results, not errors.
Comments
i ve got errors indeed when want to enable a model but it installs normally: for drupal8 and the same for drupal seven
<code> Command pm-enable needs a higher bootstrap level to run - you will [error]
need to invoke drush from a more functional Drupal environment to run
this command.
The drush command 'en page_manager' could not be executed. [error]
Drush was not able to start (bootstrap) the Drupal database. [error]
Hint: This may occur when Drush is trying to:
* bootstrap a site that has not been installed or does not have a
configured database. In this case you can select another site with a
working database setup by specifying the URI to use with the --uri
parameter on the command line. See `drush topic docs-aliases` for
details.
* connect the database through a socket. The socket file may be
wrong or the php-cli may have no access to it in a jailed shell. See
http://drupal.org/node/1428638 for details.</code>
This error usually means that you need to invoke drush from within your Drupal site. So cd into the directory where your drupal root is and then try using drush again.
These instructions are not quite correct in macos. see https://sites.google.com/site/randomprogrammingnotes/macosxsed
Thanks, Its works for me. Grt job
Hi,
Drush used to update all the modules and themes - even those that are not enabled, and this was good for a multisite (aegir) environment when site admins will want the secure, bug-fixed latest release of a module or theme. Now with drush 7.0-dev, drush will only update enabled modules and themes. Is there a flag to the up command in 7.0-dev, or is there a new command to update all modules and themes? Is this really the new INTENDED behavior of drush 7?
That's a great question and one I suggest asking in the Drush issue queue. :)
The flag you want is --check-disabled
Thank you very much. Very helpful. Was a bit confused on this one.
Glad you found it helpful!
Just a note that these instructions still work, despite Drush 7 dropping compatibility with Drupal 8. drush/drush:dev-master now points to Drush 8, which is compatible.
If you get the error:
[UnexpectedValueException] Could not parse version constraint ^2.6.3: Invalid version string
Just update the composer:
~ composer self-update
Thank you! Very helpful!
Hi Amber. I get the error "Drush 7.0.0 does not support Drupal 8"; It's different than the case you present because Drush 7.0.0 should support D8... You might have any idea to help me? Ben,
This article was published during the development phase of Drupal 8 and the details and version numbers are now out-of-date. Please follow the most recent documentation on the Drush website. As Nick pointed out below, use Drush version 8.
Ben, I got it working for Drupal8 by using drush 8.0.1 http://docs.drush.org/en/master/install-alternative/#install-a-global-d…
Hooooray! All are working OK now. Thank you!
This has me totally confused. It looks like this should be solved, but I'm still having problems. I'm trying to update my Drupal 8 site to 8.1.0, but just as this document originally described, I'm getting the error "Drush 7.0.0 does not support Drupal 8." So, I've tried to follow the instructions very carefully to upgrade Drush using Composer.
This is what returned when I ran drush up for my D8 site
fc@dell1:/var/www/d8$ ls
autoload.php example.gitignore profiles themes
composer.json index.php README.txt update.php
composer.lock LICENSE.txt robots.txt vendor
core modules sites web.config
fcromer@dell1:/var/www/d8$ drush up
Drush 7.0.0 does not support Drupal 8. [error]
Command pm-update needs a higher bootstrap level to run - you will [error]
need to invoke drush from a more functional Drupal environment to run
this command.
The drush command 'up' could not be executed. [error]
fc@dell1:/var/www/d8$
I ran fc@dell1:/var/www$ composer global require drush/drush:dev-master and returned
Changed current directory to /home/fc/.composer
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Updating drush/drush (8.0.5 => dev-master 1860a8d)
Checking out 1860a8de960b872f8282282197259b35850402df
Writing lock file
Generating autoload files
fc@dell1:/var/www$
I ran fc@dell1:/var/www$ drush status and returned
PHP executable : /usr/bin/php
PHP configuration : /etc/php5/cli/php.ini
PHP OS : Linux
Drush script : /usr/local/src/drush/drush.php
Drush version : 7.0.0
Drush temp directory : /tmp
Drush configuration :
Drush alias files :
fc@dell1:/var/www$
I've also tried running "drush dl drush." Drush status continues to report Drush version as 7.0.0. I'm running on Ubuntu 14.10
Thanks, in advance, for any help. I'm really trying to learn this.
Hi Franc,
It looks like you might have originally installed Drush 7.0.0 via another method, since the location of Drush script is
/usr/local/src
instead of/home/fc/.composer
.You can run
echo $PATH
to see the directories, in order, that are being searched for the drush executable. Make sure you are including/home/fc/.composer
in your PATH variable in your bashrc (or similar) profile.Thanks, kindly, for the reply. It was the path issue. I was able to find some instructions last night to set path as well as my .bash_profile file and that seemed to get things working.
Once again, thanks for helping out.
I have an similar problem as Franc , I have installed Drush a few months ago via another method. When I check de drush status I returns:
drush status
PHP executable : /usr/bin/php
PHP configuration : /etc/php.ini
PHP OS : Darwin
Drush version : 6.5.0
Drush configuration :
Drush alias files :
I've tried to add /home/fc/.composer into my path variables but without succes.
I've tried adding it at the end of /etc/paths and by adding 'export PATH="$PATH:/home/fc/.composer"' into ~/.bash_profile
But echo $PATH still not returns composer as expxted and drush is stil in version 6.5.0
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/DevDesktop/tools
Hi Kim, what operating system are you running? Did you restart your bash shell program or enter `source ~/.bash_profile` to reload bash_profile? If you're on OS X and not Linux, you will want to add the path '/Users/YOURUSERNAME/.composer' (not '/home/YOURUSERNAME/.composer'). Be sure to enter your own username and not 'fc' ('fc' was the previous commenter's username).
Also, it looks like you may be running Acquia DevDesktop. If so, if you are on the latest version, you should have Drush as part of that. According to their https://docs.acquia.com/dev-desktop/whats-new, Drush 8.0.5 was added in March 2016.
Here is a help page for using Drush with DevDesktop: https://docs.acquia.com/dev-desktop/sites/drush
Hi Ambermatz, thanks for your answer. I'm running on OSX. Very stupid of me I did not replace de fc with my username. I've just installed DevDesktop so I will take a look on the pages you provide, to get this working via DevDesktop.
But now I've reloaded the bash_profile as you mentioned and the faulty '/home/fc/.compser' line was added when I echo the path variables. But I can't seem to remove this now ...
Deleting it in /etc/paths and ~/.bash_profile and reloading bash_profile doesn't seem to remove it.
The path were concatenated, how can I undo this?
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/home/fc/.composer:/Applications/DevDesktop/tools:/home/fc/.composer:/Applications/DevDesktop/tools:/home/fc/.composer:/Applications/DevDesktop/tools:/home/fc/.composer:/Applications/DevDesktop/tools:/Applications/DevDesktop/tools:/Applications/DevDesktop/tools
Thanks for your help.
Restarting the iTerm application solved the issue with the faulty path variables.
But still the old drush version is loaded my path variables are shown below.
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/kim-private/.composer
The composer folder is located at the above location (/Users/kim-private/.composer) and the drush folder is located at (/Users/kim-private/.composer/vendor/).
P.S. I rather us the composer drush version instead of the DevDesktop because I prefer using iTerm instead of the default terminal DevDesktop is uses. I also read using the composer version is give more flexibility in changing drush version afterwards.
Issues fixed, drush was installed via homebrew. I've update it via hombrew and now it's working in de latest version.
More information on http://www.patrickcoffey.io/post/upgrading-drush-7-drupal-8-osx-homebrew
Hello great website.
Add new comment