• Support
  • How to install drush for Drupal 7

Does anyone have experience installing Drush for Drupal 7 on Opalstack?

Thanks.

5 days later

Apologies for the late reply!

I've got instructions to install the latest Drush & Drupal. Maybe they can be adapted to your case:

  1. Create a shell user for your app if you've not done so already.
  2. Create a MariaDB database and user and make a note of the DB name and credentials.
  3. SSH to your server as your shell user.
  4. Install Composer by following these instructions: Installing Composer
  5. Install Drupal and Drush, providing your database credentials when prompted:
        cd ~
        composer create-project drupal/recommended-project mysite 
        cd mysite
        composer require drush/drush
        ./vendor/bin/drush site:install
  6. Create a symlink app using /home/shelluser/mysite/web/ as the symlink path and attach that app to your site.

(I used mysite as the Drupal install directory but you can change that to whatever you need it to be.)

    8 months later

    Hello.
    I have the next issue:

    Running composer update drush/drush --with-all-dependencies
    Loading composer repositories with package information
    Updating dependencies
    Your requirements could not be resolved to an installable set of packages.

    Problem 1
    - composer/installers is locked to version v1.5.0 and an update of this package was not requested.
    - composer/installers v1.5.0 requires composer-plugin-api 1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
    Problem 2
    - wikimedia/composer-merge-plugin is locked to version v1.4.1 and an update of this package was not requested.
    - wikimedia/composer-merge-plugin v1.4.1 requires composer-plugin-api 1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.

    You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.

      josueValrob Fixed with
      composer self-update --1

      [valrob@opal6 admin]$ composer require drush/drush
      Using version 10.3 for drush/drush
      ./composer.json has been updated
      Loading composer repositories with package information
      Updating dependencies (including require-dev)
      Your requirements could not be resolved to an installable set of packages.

      Problem 1
      - Conclusion: don't install twig/twig v1.44.2
      - Conclusion: don't install twig/twig v1.44.1
      - Conclusion: don't install twig/twig v1.44.0
      - Conclusion: don't install twig/twig v1.43.1
      - Conclusion: don't install twig/twig v1.43.0
      - Conclusion: don't install twig/twig v1.42.5
      - Conclusion: don't install twig/twig v1.42.4
      - Conclusion: don't install twig/twig v1.42.3
      - Conclusion: don't install twig/twig v1.42.2
      - Conclusion: don't install twig/twig v1.42.1
      - Conclusion: don't install twig/twig v1.42.0
      - Conclusion: don't install twig/twig v1.41.0
      - Conclusion: don't install drush/drush 10.3.6
      - Conclusion: don't install drush/drush 10.3.5
      - Conclusion: don't install drush/drush 10.3.4
      - Conclusion: don't install drush/drush 10.3.3
      - Conclusion: don't install drush/drush 10.3.2
      - Conclusion: don't install drush/drush 10.3.1
      - Conclusion: don't install drush/drush 10.3.0
      - Conclusion: don't install drush/drush 10.4.0-rc1
      - Conclusion: remove twig/twig v1.35.3
      - Installation request for drush/drush 10.3 -> satisfiable by drush/drush[10.3.0, 10.3.1, 10.3.2, 10.3.3, 10.3.4, 10.3.5, 10.3.6, 10.4.0-rc1, 10.x-dev].
      - Conclusion: don't install twig/twig v1.35.3
      - drush/drush 10.x-dev requires chi-teck/drupal-code-generator 1.32.1 -> satisfiable by chi-teck/drupal-code-generator[1.32.1, 1.33.0, 1.33.1, 1.x-dev].
      - chi-teck/drupal-code-generator 1.32.1 requires twig/twig 1.41 2.12 -> satisfiable by twig/twig[1.x-dev, 2.x-dev, v1.41.0, v1.42.0, v1.42.1, v1.42.2, v1.42.3, v1.42.4, v1.42.5, v1.43.0, v1.43.1, v1.44.0, v1.44.1, v1.44.2].
      - chi-teck/drupal-code-generator 1.33.0 requires twig/twig 1.41
      2.12 -> satisfiable by twig/twig[1.x-dev, 2.x-dev, v1.41.0, v1.42.0, v1.42.1, v1.42.2, v1.42.3, v1.42.4, v1.42.5, v1.43.0, v1.43.1, v1.44.0, v1.44.1, v1.44.2].
      - chi-teck/drupal-code-generator 1.33.1 requires twig/twig 1.41 2.12 -> satisfiable by twig/twig[1.x-dev, 2.x-dev, v1.41.0, v1.42.0, v1.42.1, v1.42.2, v1.42.3, v1.42.4, v1.42.5, v1.43.0, v1.43.1, v1.44.0, v1.44.1, v1.44.2].
      - chi-teck/drupal-code-generator 1.x-dev requires twig/twig 1.41
      2.12 -> satisfiable by twig/twig[1.x-dev, 2.x-dev, v1.41.0, v1.42.0, v1.42.1, v1.42.2, v1.42.3, v1.42.4, v1.42.5, v1.43.0, v1.43.1, v1.44.0, v1.44.1, v1.44.2].
      - Can only install one of: twig/twig[1.x-dev, v1.35.3].
      - Can only install one of: twig/twig[2.x-dev, v1.35.3].
      - Installation request for twig/twig (locked at v1.35.3, required as 1.35.0) -> satisfiable by twig/twig[v1.35.3].

      Installation failed, reverting ./composer.json to its original content.

      managed to installed, but still not working:

      [valrob@opal6 admin]$ ./vendor/bin/drush --version
      Drush Commandline Tool 10.3.6
      [valrob@opal6 admin]$ ./vendor/bin/drush cc

      In CheckExceptionOnInvalidReferenceBehaviorPass.php line 31:


      The service "config.import.commands" has a dependency on a non-existent service "extension.list.module".


      cache:clear [--cache-clear [CACHE-CLEAR]] [--no-cache-clear] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-d|--debug] [-y|--yes] [--no] [--remote-host REMOTE-HOST] [--remote-user REMOTE-USER] [-r|--root ROOT] [-l|--uri URI] [--simulate] [--pipe] [-D|--define DEFINE] [--druplicon] [--notify [NOTIFY]] [--xh-link XH-LINK] [--] <command> <type> [<args>]...

      • sean replied to this.

        josueValrob I think you've got some kind of version mismatch between some combination of PHP, Drupal, drush and/or composer.

          7 months later
          4 months later

          How would I install drush for an existing installation of Drupal 7 (like one that was ported over from webfaction).

          I have been singularly unsuccessful at installing the correct version of drush (one that is compatible with Drupal 7 (like 8.4.8).

          I've mucked something up, but I'm not sure exactly how. The version of drush that runs outside of the app directory is 8.4.8 and seems a little broken. The version of drush that runs inside my app directory is 10.6.1 (not compatible with Drupal 7.

          How do I fix this?

          I want to run drush 8.4.8 everywhere (it's compatible with most versions of Drupal I use).

          The installation instructions here are quite opaque.

          Thanks in advance,
          Dave

          • sean replied to this.

            kabal to install Drush 8.4.8, go into whichever app directory and run:

            composer require drush/drush:8.4.8

              sean

              `
              [kabal@opal4 rescueminute]$ composer require drush/drush:8.4.8
              ./composer.json has been updated
              Running composer update drush/drush
              Loading composer repositories with package information
              Updating dependencies
              Your requirements could not be resolved to an installable set of packages.

              Problem 1
              - Root composer.json requires drush/drush 8.4.8 -> satisfiable by drush/drush[8.4.8].
              - drush/drush 8.4.8 requires consolidation/annotated-command 2.12.0 -> found consolidation/annotated-command[2.12.0, 2.12.1] but the package is fixed to 4.4.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

              Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

              Installation failed, reverting ./composer.json and ./composer.lock to their original content.
              [kabal@opal4 rescueminute]$
              `

              Cheers,
              Dave

              • sean replied to this.

                kabal you could try a standalone installation like so:

                mkdir ~/drush
                cd ~/drush
                composer require drush/drush:8.4.8
                export PATH=$HOME/drush/vendor/bin:$PATH

                This will give you a single drush installed in ~/drush that you can use with whatever Drupal 7 sites you have.

                  sean Installation above worked perfectly. Refuses to use the correct version.

                  [kabal@opal4 rescueminute]$ which drush
                  ~/drush/vendor/bin/drush
                  [kabal@opal4 rescueminute]$ drush status
                  PHP binary : /usr/bin/php
                  PHP config : /etc/php.ini
                  PHP OS : Linux
                  Drush script : /home/kabal/apps/rescueminute/vendor/drush/drush/drush
                  Drush version : 10.6.1
                  Drush temp : /tmp
                  Drush configs : /home/kabal/apps/rescueminute/vendor/drush/drush/drush.y
                  ml

                  OK SOMETHING is working. I deleted the vendor/drush directory.

                  Every drush command produces the following error, but seems to succeed:

                  [kabal@opal4 rescueminute]$ drush up
                  sh: module: line 1: syntax error: unexpected end of file
                  sh: error importing function definition for 'BASH_FUNC_module'

                  OR

                  [kabal@opal4 rescueminute]$ drush status
                  sh: module: line 1: syntax error: unexpected end of file
                  sh: error importing function definition for 'BASH_FUNC_module'

                  So.... progress.

                  • sean replied to this.

                    sean Awesome, the second one worked (first one not so much).

                    a year later

                    kabal It looks like composer is either not installed or not included in your PATH. You might need to restart your SSH terminal session after installing composer, or just use the path in the command when running it, eg.
                    ~/bin/composer require drush/drush:8.4.8

                    a year later

                    sean after reading this, I downgraded Drush from 10 to 9 on my Drupal 8 site with PHP 7.3, it worked perfectly. Thank you!

                    Mastodon