Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lando acli pull:db not working as expected #27

Open
schmentle opened this issue Jan 10, 2022 · 1 comment
Open

lando acli pull:db not working as expected #27

schmentle opened this issue Jan 10, 2022 · 1 comment

Comments

@schmentle
Copy link

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:

 ! [NOTE] Acquia CLI assumes that the Lando database name for the mtndecoupled database is mtndecoupled
✔ Importing mtndecoupled database download

The default database created is setup with:

      user: acquia
      password: acquia
      database: acquia

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:

name: mtndecoupled
recipe: acquia
config:
  acli_version: master
  ah_site_group: mtndecoupled
  php: '7.4'
services:
  phpmyadmin:
    type: phpmyadmin
    hosts:
      - database
  database:
    type: mysql
    portforward: true
    creds:
      user: acquia
      password: acquia
      database: mtndecoupled

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.

@rtfm-47 rtfm-47 transferred this issue from lando/lando Jan 10, 2022
@wesleymusgrove
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants