Open schmentle opened 2 years ago
I experienced this issue after ACLI updated to any version newer than 2.11.1
, https://github.com/acquia/cli/releases/download/2.11.1/acli.phar. I was actually using the latest version instead of pinning it to a specific version of ACLI, https://github.com/acquia/cli/releases/latest/download/acli.phar, so when I did a lando rebuild
it ran into the error.
I use the "drupal9" and "drupal10" recipes rather than the "acquia" recipe.
Here's a tooling command that installs ACLI. I think the "acquia" recipe ships with the latest version of ACLI so you don't have to install it manually, but I'm not 100% about that.
tooling:
acli-install:
service: appserver
cmd:
## Uncomment this if you need to remove it and re-install it
#- rm /usr/local/bin/acli && rm -rf ~/.acquia && rm -rf ~/.acquia*
## Install the latest version of ACLI
- curl -OL https://github.com/acquia/cli/releases/latest/download/acli.phar
## Or use a specific version
#- curl -OL https://github.com/acquia/cli/releases/download/2.11.1/acli.phar
- chmod +x acli.phar
- mv acli.phar /usr/local/bin/acli
- acli auth:login
Here's the error where it tries to connect to the local database with the wrong username/password/database schema name. The default username/password/database for the "drupal10" recipe is.... "drupal10", not "drupal".
acli pull:database -vvv
Box Requirements Checker
========================
> Using PHP 8.1.18
> PHP is using the following php.ini file:
WARNING: No configuration file (php.ini) used by PHP!
> Checking Box requirements:
✔ The application requires a version matching "^8.0".
✔ The application requires the extension "json".
✔ The package "guzzlehttp/guzzle" requires the extension "json".
✔ The package "league/csv" requires the extension "json".
✔ The package "m4tthumphrey/php-gitlab-api" requires the extension "json".
✔ The package "ramsey/uuid" requires the extension "json".
✔ The package "zumba/amplitude-php" requires the extension "json".
✔ The package "composer/ca-bundle" requires the extension "openssl".
✔ The package "composer/ca-bundle" requires the extension "pcre".
✔ The package "vlucas/phpdotenv" requires the extension "pcre".
✔ The package "m4tthumphrey/php-gitlab-api" requires the extension "xml".
✔ The package "marc-mabe/php-enum" requires the extension "reflection".
✔ The package "zumba/amplitude-php" requires the extension "curl".
✔ The package "laminas/laminas-servicemanager" conflicts with the extension "psr".
✔ The package "symfony/dependency-injection" conflicts with the extension "psr".
✔ The package "symfony/service-contracts" conflicts with the extension "psr".
[OK] Your system is ready to run the application.
Notice: Composer script `pre-acli-pull-database` does not exist in `/app/composer.json`, skipping. This is not an error.Acquia CLI version: 2.15.1
Connecting to database drupal
[notice] Command: 'which' 'mysql' [Exit: 0]
ERROR
2002 (HY000)
: Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
[notice] Command: 'mysql' '--host' 'localhost' '--user' 'drupal' 'drupal' [Exit: 1]
In PullCommandBase.php line 334:
[Acquia\Cli\Exception\AcquiaCliException]
Unable to connect to local database using credentials mysql:://drupal:drupal@localhost/drupal. ERROR 2002 (HY000):
Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
Exception trace:
at phar:///usr/local/bin/acli/src/Command/Pull/PullCommandBase.php:334
Acquia\Cli\Command\Pull\PullCommandBase->connectToLocalDatabase() at phar:///usr/local/bin/acli/src/Command/Pull/PullCommandBase.php:115
Acquia\Cli\Command\Pull\PullCommandBase->pullDatabase() at phar:///usr/local/bin/acli/src/Command/Pull/PullDatabaseCommand.php:48
Acquia\Cli\Command\Pull\PullDatabaseCommand->execute() at phar:///usr/local/bin/acli/vendor/symfony/console/Command/Command.php:298
Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/acli/src/Command/CommandBase.php:242
Acquia\Cli\Command\CommandBase->run() at phar:///usr/local/bin/acli/vendor/symfony/console/Application.php:1058
Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/acli/vendor/symfony/console/Application.php:301
Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/acli/vendor/symfony/console/Application.php:171 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/acli/bin/acli:105
require() at /usr/local/bin/acli:14
I realized that when I looked at the help documentation for the command acli pull:database --help
This command requires an active database connection. Set the following environment variables prior to running this command: ACLI_DB_HOST, ACLI_DB_NAME, ACLI_DB_USER, ACLI_DB_PASSWORD
So I ran lando info
to get the database connection credentials and put those in my lando.yml file and set up a tooling command for acli pull:database
. I know you should not put the database credentials in plain text like this in your lando.yml file, but instead use a separate env_file, like this: https://docs.lando.dev/core/v3/env.html#environment-files
tooling:
acli-pull-database:
service: appserver
cmd: acli pull:database
env:
ACLI_DB_HOST: 'database'
ACLI_DB_NAME: 'drupal10'
ACLI_DB_USER: 'drupal10'
ACLI_DB_PASSWORD: 'drupal10'
After specifying those env vars, the database pull works successfully and is able to connect and import into my local database.
I tried searching the issues, but couldn't find the same issue I'm having. I've noticed an issue with the recent version of Lando (v3.6.0) that the
lando acli pull:db
does not work like it used to.Whilst running it, I see this notice:
The default database created is setup with:
I tried adding in my default database details, but it doesn't connect to the database when trying to run the command again. Neither does the Drupal site (can't connect to the database).
Adding the default database details in the
.lando.yml
file:Not sure if I'm doing this correctly for config, any help would be appreciated on that.
The other solution seems to be working
lando pull --code=none --database=dev --files=none
which is great and might be more ideal to use, but just want to find out if this is the recommended way now so I can let my team know.