Too few arguments to function
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
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.)
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.
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.
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.
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.
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'.
Ran update.php and issue has been resolved
For me works an update to the drush version 10.
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.