Drush can not find settings.php 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.
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