0

I am running LAMP on Ubuntu 16.04. I have a drupal 7 installation and I have installed drush 8.1.3 via Composer version 1.5.2. I believe there is bug in php7.2 causing the error as discussed on Github, however even after I applied the recommended fix which is to update the pear/console_table to the latest version instructed here, the problem still remains. I also followed the instructions on Super User to be absolutely sure that I have the most up to date version of pear installed as well (did not install PHPunit). And, FYI in accordance with the drush installation documentation found here, I also made the proper changes to my .bashrc file as well (below).

Whenever I run drush status I receive the following error:

[UPDATE: This part of problem SOLVED by @GiorgosK answer below. Other problems persist due to Drush not find mysql socket]

count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
count(): Parameter must be an array or an object that implements     [warning]
Countable Table.php:789
PHP executable         :  /usr/bin/php                                 
PHP configuration      :  /etc/php/7.2/cli/php.ini                     
PHP OS                 :  Linux                                        
Drush script           :  /home/webdevusr/vendor/drush/drush/drush.php 
Drush version          :  8.1.13                                       
Drush temp directory   :  /tmp                                         
Drush configuration    :                                               
Drush alias files      :   

If I execute drush sql-connect

Unable to load class Drush\Sql\Sql                                  [error]
Drush\Sql\SqlException: Unable to find a matching SQL Class. Drush   [error]
cannot find your database connection details. in
/home/webdevusr/vendor/drush/drush/commands/sql/sql.drush.inc:541
Stack trace:
#0
/home/webdevusr/vendor/drush/drush/commands/sql/sql.drush.inc(221):
drush_sql_get_class()
#1 /home/webdevusr/vendor/drush/drush/includes/command.inc(422):
drush_sql_connect()
#2 /home/webdevusr/vendor/drush/drush/includes/command.inc(231):
_drush_invoke_hooks(Array, Array)
#3 /home/webdevusr/vendor/drush/drush/includes/command.inc(199):
drush_command()
#4
/home/webdevusr/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67):
drush_dispatch(Array)
#5 /home/webdevusr/vendor/drush/drush/includes/preflight.inc(66):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#6 /home/webdevusr/vendor/drush/drush/drush.php(12): drush_main()
#7 {main}

The contents of my ~/.bashrc file, are as follows:

export PATH="$HOME/.composer/vendor/bin:$PATH"

export PATH=/bin:/usr/local/bin:/usr/local/mysql/bin:$PATH

# Include Drush bash customizations.
if [ -f "/home/webdevusr/.drush/drush.bashrc" ] ; then
source /home/webdevusr/.drush/drush.bashrc
fi

# Include Drush completion.

if [ -f "/home/webdevusr/.drush/drush.complete.sh" ] ; then
source /home/webdevusr/.drush/drush.complete.sh
fi

# Include Drush prompt customizations.

if [ -f "/home/webdevusr/.drush/drush.prompt.sh" ] ; then
source /home/webdevusr/.drush/drush.prompt.sh
fi

The result of drush cc all executed from within my drupal installation folder is:

No Drupal site found, only 'drush' cache was cleared. 

Anyone know how to get drush to working for my local (LAMP) Drupal 7 installations?

thx

3
  • Try putting export PATH="$HOME/.composer/vendor/bin:$PATH" export PATH=/bin:/usr/local/bin:/usr/local/mysql/bin:$PATH in your ~/.bash_profile instead of ~/.bashrc.
    – Christia
    Commented Sep 24, 2017 at 3:32
  • @christia thx for the reply. Haven't had a chance to try this yet b/c an update to mysql crashed all of my lamp drupal sites. I now need to post my new problem, then return to this... but I'll be sure to let u know if your suggestion helps
    – yupthatguy
    Commented Oct 12, 2017 at 17:45
  • State clearly what part is still giving you trouble ... I have updated my answer with more info
    – GiorgosK
    Commented Mar 9, 2018 at 7:36

2 Answers 2

1

Recently run into a similar problem on my local environment after an ubuntu update and php 7.2 became my default version.

make 7.1 or lower your default php version

I believe you should make php 7.1 the default or perhaps even a lower php version for Drupal 7 installation as not all modules are ready for php 7.2 (even some of Drupal 8 modules are not ready for php 7.2)

type this in your shell

$ sudo update-alternatives --config php

and this is what you will get

There are 4 choices for the alternative php (providing /usr/bin/php).

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/php7.2   72        auto mode
  1            /usr/bin/php5.6   56        manual mode
  2            /usr/bin/php7.0   70        manual mode
  3            /usr/bin/php7.1   71        manual mode
  4            /usr/bin/php7.2   72        manual mode
Press <enter> to keep the current choice[*], or type selection number:

Choose the appropriate version

might need to update drush to a later version.

8.1.16 is out at this moment and might already have solved the problem you describe. Update using composer

alternatively you can try to setup drush without composer

# get drush latest 8 version from 
# https://github.com/drush-ops/drush/releases
wget https://github.com/drush-ops/drush/releases/download/8.1.16/drush.phar

# make it executable
chmod +x drush.phar;

# move it to home directory or any other directory
mv drush.phar ~/drush;

# go to that directory
cd ~

# find out the path to the directory
pwd
# the output would look similar to this
# /home/your_user

# edit the following file 
nano .bashrc
# or 
# nano .bash_profile

# add this the end of the file
alias drush='/home/your_user/drush';

# use the alias you just setup
source ~/.bashrc;

might want to specify site directory when you invoke drush

as you drush might have a messed up setup/aliases

drush status -r /path/to/site/rootdir

doublecheck your settings.php

Does it include the correct database connections? Does the site actually run with those connection settings ?

Look in your logs for any problems

in my system I can see apache errors like this

tail -50 /var/log/apache2/error.log 

You might discover that some apache packages are missing or disabled just an example lets say mod_rewrite is not enabled

sudo a2enmod rewrite
sudo service apache2 restart

or you might find that some package is missing like mysql-client

sudo apt-get install mysql-client
8
  • I dropped PHP down to 5.6 and that eliminated my first problem described above... However, drush sql-connect and drush cc all still return the same error... can't find the database... good solid progress.. @GiorgosK thanks
    – yupthatguy
    Commented Feb 26, 2018 at 3:08
  • Posted a few more things to try out.
    – GiorgosK
    Commented Feb 26, 2018 at 6:11
  • Thx for your help, one more step to get drush working. I located my LAMP mysql socket @ /run/mysqld/mysqld.sock but I can't figure out to point drush to find it.... any thoughts would be greatly useful... everything on the web is MAMP, not LAMP instructions
    – yupthatguy
    Commented Mar 8, 2018 at 21:45
  • drush is driving me nuts... slowing me down. From my original post whenever I run drush sql-connect I still get the same error... I am running from inside the actual drupal folder. I checked the error log and double checked that rewrite and mysql-client were both installed/working.. I even tried point to the mysql socket using settings.php 'unix_socket'='path/to/socket', still no luck.. get to this to work and my lamp is perfect...banging head on wall now.. ;-|
    – yupthatguy
    Commented Mar 10, 2018 at 1:51
  • Thanks for the help... I figured out what was wrong... I completely uninstalled global drush via composer... and installed drush to the us in folder... but I noticed instead of running 8.1.16, I was still running 8.1.13 so I went to the home/vendor and deleted the drush folder there... everything now works perfectly... thx for the assist... your alternative method worked
    – yupthatguy
    Commented Mar 10, 2018 at 15:05
0

I recently ran into the same issue, and for us it turned out that Drush 8 relies on several packages being installed on the server. In our case, we needed mysql-client to be installed.

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.