2

I use two shared hosts at present. One, webhostinghub.com, already has drush installed and it works. The other, 1and1.com, did not come with drush pre-installed so I installed composer and then drush with composer as recommended on drupal.org.

This puts a symlink to drush in ~/.composer/vendor/bin which points to ../drush/drush/drush. In the ~/.composer/vendor/drush/drush folder that this points to is a file drush which requires drush.php which is in the same folder.

So as recommended, I set up an alias for drush that runs this with php-cli. Because 1and1.com sets up php and php-cli to default to php4, I also set up an alias for both php and php-cli to the php7.1 versions.

When I go to the root folder of one of my drupal sites and type in simply drush, I get the non Drupal specific commands listed and then the message:

NOTE: Drupal root not found. Pass --root or a @siteAlias in order to see Drupal-specific commands.

I did see some posts saying that for this to work you have to just have one settings.php in the sites/default folder of the drupal tree. I have searched and have not found any stray settings.php files - just the one in the sites/default folder.

Does any one have an idea about why this is not working? Let me know if you need more information about my setup or the process that I went through.

6
  • What version of Drupal are you using? Can you post the error message when you run drush status?
    – Christia
    Apr 24, 2018 at 0:30
  • 2
    In settings.php, for your database settings, if it says 'localhost' try changing it to '127.0.0.1'
    – Jaypan
    Apr 24, 2018 at 1:13
  • Thanks for the swift responses. @Christia I am running Drupal 7.58 and Drush 9.3-dev-gd9b1af0. The drupal version is the same but the drush version on the other server is 8.1.10. Does that make a difference? Jaypan - 1and1 does not use localhost but gives a specific host and port for the database server so that is how my settings.php is coded. This is different for webhostinghub who use localhost and default port.
    – Rory
    Apr 24, 2018 at 6:31
  • @Christia. I meant to say I don't get an error message on drush status. The message I refer to is when I type just drush. Thanks again
    – Rory
    Apr 24, 2018 at 12:09
  • 1
    I have just spotted that Drupal 7 and drush 9 are not compatible! Once I have downgrade I shall report in an answer, including how to downgrade in case any one else gets the same issue, assuming all goes well!
    – Rory
    Apr 24, 2018 at 12:26

1 Answer 1

2

I was right in my comment earlier. The issue was compatibility between drush 9 and drupal 7. Once I downgraded to drush 8.1.10 it worked fine. Note there is also an oddity with 1and1 specifically where in SSH they default to php4.4 which is too old! So I also had to set up an alias for php and php-cli to refer to a more modern php. Also I had to ensure drush used it by adding 'export DRUSH_PHP=' followed by the full path and filename for the more recent version of php.

If anyone reading this does not know how to downgrade drush with composer you have to remove and re add it with the following commands:

composer global remove drush/drush

composer global require drush/drush:8.1.10

Replace the 8.1.10 with the version that you want.

Also, anyone new to composer might get fooled as I did by the prompt 'Discard changes? (y/n/v/d/s/?). Yes actually means 'discard and apply changes'! I found details of this in the following post: https://stackoverflow.com/questions/25828102/composer-discard-changes-what-do-the-y-n-v-d-s-do

I hope this helps anyone else new like me stumbling across this issue!

Once again thanks for the comments - the one question from @Christia about drupal version triggered me to look in the right direction!

Rory

1
  • At this time, I think 8.1.17 might be a good bet.
    – Gervase
    Jan 15, 2019 at 17:26

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.