drush icon indicating copy to clipboard operation
drush copied to clipboard

Too few arguments to function

Open magick93 opened this issue 9 years ago • 9 comments

When running drush dl bootstrap I get the following:

ArgumentCountError: Too few arguments to function Drush\Sql\SqlBase::__construct(), 1 passed and exactly 2 expected in /var/www/html/vendor/drush/drush/src/Sql/SqlBase.php on line 29 #0 [internal function]: Drush\Sql\SqlBase->__construct(Array)
#1 /home/www-data/.composer/vendor/drush/drush/includes/drush.inc(117): ReflectionClass->newInstanceArgs(Array)
#2 /home/www-data/.composer/vendor/drush/drush/commands/sql/sql.drush.inc(519): drush_get_class('Drush\\Sql\\Sql', Array, Array)
#3 /home/www-data/.composer/vendor/drush/drush/commands/sql/sql.drush.inc(536): drush_sql_get_class(Array)
#4 /home/www-data/.composer/vendor/drush/drush/includes/environment.inc(384): drush_sql_get_class()
#5 /home/www-data/.composer/vendor/drush/drush/lib/Drush/Boot/DrupalBoot.php(462): drush_valid_db_credentials()
#6 /home/www-data/.composer/vendor/drush/drush/lib/Drush/Boot/DrupalBoot8.php(109): Drush\Boot\DrupalBoot->bootstrap_drupal_database_validate()
#7 /home/www-data/.composer/vendor/drush/drush/includes/bootstrap.inc(430): Drush\Boot\DrupalBoot8->bootstrap_drupal_database_validate()
#8 /home/www-data/.composer/vendor/drush/drush/includes/bootstrap.inc(507): drush_bootstrap_validate(4)
#9 /home/www-data/.composer/vendor/drush/drush/includes/bootstrap.inc(456): drush_bootstrap_max()
#10 /home/www-data/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(59): drush_bootstrap_to_phase(-2)
#11 /home/www-data/.composer/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#12 /home/www-data/.composer/vendor/drush/drush/drush.php(12): drush_main()
#13 {main}
ArgumentCountError: Too few arguments to function Drush\Sql\SqlBase::__construct(), 1 passed and exactly 2 expected in Drush\Sql\SqlBase->__construct() (line 29 of /var/www/html/vendor/drush/drush/src/Sql/SqlBase.php).
Drush command terminated abnormally due to an unrecoverable error.  

I am also getting the same error when running drush st - and seemingly any drush command - from in the docroot directory.

Version

drush --version Drush Version : 8.1.12

magick93 avatar Oct 09 '17 22:10 magick93

I think that sometimes Drush provides poor error output similar to the above when your sql server is not working right. Check to make sure that the php-cli can connect to the database using the credentials in your setting.php (and that the right settings.php is selected via --uri, etc.)

greg-1-anderson avatar Oct 09 '17 22:10 greg-1-anderson

Thanks @greg-1-anderson

Im not using sql server, but am using mysql.

Check to make sure that the php-cli can connect to the database using the credentials in your setting.php (and that the right settings.php is selected via --uri, etc.)

Do you have any docs that describes these steps for a newbie? I tried drush --uri and drush --help but didnt see anything about --uri.

magick93 avatar Oct 09 '17 22:10 magick93

Im not sure why this is closed.

Drupal is able to connect to the database.

But Drush, when issued a command that shouldnt require even connecting to the database, complains about throws a Too few arguments exception.

Not only is the exception wrong - the correct number of parameters is supplied, but drush shouldnt need to connect to the database in this case.

magick93 avatar Oct 13 '17 01:10 magick93

If you dont want dl to connect to the DB, run it from outside the drupal site. otherwise, it bootstraps drupal so that hooks can participate and dl command figure out th optimum destination for the new project.

weitzman avatar Oct 13 '17 01:10 weitzman

Ok. So there is a good reason for drush to connect to db, even when downloading a theme.

Nonetheless, in this instance, drush is seemingly throwing an incorrect exception.

magick93 avatar Oct 13 '17 01:10 magick93

For me, adding the command line parameter --root=/path/to/my/drupal-7 solved this issue with Drush 8.3.0.

Adding the parameter is even necessary when my current working directory is exactly what I specify with --root=. This was because my "/home/vagrant/.drush/drushrc.php" file defined a default $options['root'] = '/path/to/drupal8'.

Gogowitsch avatar Aug 04 '19 06:08 Gogowitsch

Ran update.php and issue has been resolved

andbier avatar Feb 13 '20 00:02 andbier

For me works an update to the drush version 10.

sreher avatar Mar 24 '20 21:03 sreher

In my case, I was removing the composer.(json/lock) while creating the deployment artefact. It is needed apparently. Composer's meaning has drastically increased nowadays.

hugronaphor avatar Oct 27 '20 15:10 hugronaphor