welaika / wordmove

Multi-stage command line deploy/mirroring and task runner for Wordpress
https://wptools.it/wordmove
MIT License
1.87k stars 165 forks source link

database pull fails at wp search-replace: "Error: This does not seem to be a WordPress installation." #639

Closed castilma closed 2 years ago

castilma commented 2 years ago

Describe the bug

I want to pull a remote db to a local wp installation.

Wordmove command

wordmove pull -d

Expected behavior

I expect the command to exit with no error.

movefile.yml

global:
  sql_adapter: wpcli

local:
  vhost: "https://***.local"
  wordpress_path: "/Users/me/Local Sites/***/app/public/" # use an absolute path here

  database:
    name: ***
    user: ***
    password: "***" # could be blank, so always use quotes around
    host: localhost
    mysql_options: '--socket="/Users/me/Library/Application\ Support/Local/run/.../mysql/mysqld.sock"'
    mysqldump_options: '--socket="/Users/me/Library/Application\ Support/Local/run/.../mysql/mysqld.sock"'

staging:
  vhost: https://***/
  wordpress_path: /html/***-staging # use an absolute path here

  database:
    name: ***
    user: ***
    password: "***"
    host: ***

  exclude:
    - '.git/'
    - '.gitignore'
    #[...]

  ssh:
#[ssh settings ...]

Exception/trace

▬▬ Using Movefile: ./movefile.yml ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

▬▬ Pulling Database ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

    local | mysqldump --host=[secret] --user=[secret] --password=[secret] --result-file="[secret]wp-content/local-backup-1643576704.sql" --socket=/...mysqld.sock local
mysqldump: [Warning] Using a password on the command line interface can be insecure.

    local | gzip -9 -f "[secret]wp-content/local-backup-1643576704.sql"

   remote | mysqldump --host=[secret] --user=*** --password=*** --result-file="[secret]/wp-content/dump.sql" ***

   remote | gzip -9 -f "[secret]/wp-content/dump.sql"

   remote | get: [secret]/wp-content/dump.sql.gz [secret]wp-content/dump.sql.gz

   remote | delete: [secret]/wp-content/dump.sql.gz

    local | gzip -d -f "[secret]wp-content/dump.sql.gz"

    local | mysql --host=[secret] --user=[secret] --password=[secret] --database=local --socket=/...mysqld.sock --execute="SET autocommit=0;SOURCE [secret]wp-content/dump.sql;COMMIT"
mysql: [Warning] Using a password on the command line interface can be insecure.

    local | adapt dump for vhost

    local | wp search-replace --path=WP_CLI_CONFIG_PATH [secret] [secret] --quiet --skip-columns=guid --all-tables --allow-[secret]
Error: This does not seem to be a WordPress installation.
Pass --path=`path/to/wordpress` or run `wp core download`.
Traceback (most recent call last):
    14: from /Users/me/.gem/ruby/2.7.0/bin/wordmove:23:in `<main>'
    13: from /Users/me/.gem/ruby/2.7.0/bin/wordmove:23:in `load'
    12: from /Users/me/.gem/ruby/2.7.0/gems/wordmove-5.2.2/exe/wordmove:6:in `<top (required)>'
    11: from /Users/me/.gem/ruby/2.7.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
    10: from /Users/me/.gem/ruby/2.7.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
     9: from /Users/me/.gem/ruby/2.7.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
     8: from /Users/me/.gem/ruby/2.7.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
     7: from /Users/me/.gem/ruby/2.7.0/gems/wordmove-5.2.2/lib/wordmove/cli.rb:91:in `pull'
     6: from /Users/me/.gem/ruby/2.7.0/gems/wordmove-5.2.2/lib/wordmove/cli.rb:39:in `handle_options'
     5: from /Users/me/.gem/ruby/2.7.0/gems/wordmove-5.2.2/lib/wordmove/cli.rb:39:in `each'
     4: from /Users/me/.gem/ruby/2.7.0/gems/wordmove-5.2.2/lib/wordmove/cli.rb:40:in `block in handle_options'
     3: from /Users/me/.gem/ruby/2.7.0/gems/wordmove-5.2.2/lib/wordmove/cli.rb:92:in `block in pull'
     2: from /Users/me/.gem/ruby/2.7.0/gems/wordmove-5.2.2/lib/wordmove/deployer/ssh.rb:48:in `pull_db'
     1: from /Users/me/.gem/ruby/2.7.0/gems/wordmove-5.2.2/lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb:37:in `adapt_remote_db!'
/Users/me/.gem/ruby/2.7.0/gems/wordmove-5.2.2/lib/wordmove/deployer/base.rb:95:in `run': Return code reports an error (Wordmove::ShellCommandError)

Environment (please complete the following information):

Doctor

(I believe those errors are unrelated.)

 ▬▬ Using Movefile: ./movefile.yml ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

▬▬ Validating movefile section: global ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

    ✅  success | Formal validation passed

▬▬ Validating movefile section: local ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

    ❌  error | [/database/mysql_options] key 'mysql_options:' is undefined.

▬▬ Validating movefile section: staging ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

    ✅  success | Formal validation passed

▬▬ Using Movefile: ./movefile.yml ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

▬▬ Checking local database commands and connection ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

    ✅  success | `mysql` command is in $PATH

    ✅  success | `mysqldump` command is in $PATH

    ❌  error |   We can't connect to the MySQL server using credentials
                specified in the Movefile. Double check them or try
                to debug your system configuration.

                The command used to test was:

                mysql --host=localhost --user=*** --password=*** -e'QUIT'

    ❌  error |   We can't connect to the database using credentials
                specified in the Movefile, or the database does not
                exists. Double check them or try to debug your
                system configuration.

                The command used to test was:

                mysql --host=localhost --user=*** --password=*** *** -e'QUIT'

▬▬ Checking local wp-cli installation ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

    ✅  success | wp-cli is correctly installed

    ✅  success | wp-cli is up to date

▬▬ Checking rsync ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

    ✅  success | rsync is installed at version 2.6.9

▬▬ Checking SSH client ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

    ✅  success | SSH command found
castilma commented 2 years ago

I'm a newbie. If I had to guess, it looks to me like wp search-replace is called with a wrong --path argument. The value should maybe not be literally "WP_CLI_CONFIG_PATH", but the actual path on the local machine?

alessandro-fazzi commented 2 years ago

I don't know - as it stands - how WP_CLI_CONFIG_PATH could have been appeared there, but my guess is that the cause should be your local path:

wordpress_path: "/Users/me/Local Sites/***/app/public/"

since it contains spaces you should escape them

wordpress_path: "/Users/me/Local\ Sites/***/app/public/"

or, even better, rename your folder with a more geek-friendly name like LocalSites :)

castilma commented 2 years ago

Found the problem. I work with someone else on this wp installation and my partner added a wp-cli.yml file with the following content: path: WP_CLI_CONFIG_PATH

He was trying something out, but forgot to remove it afterwards.

castilma commented 2 years ago

since it contains spaces you should escape them wordpress_path: "/Users/me/Local\ Sites/***/app/public/"

I think wordmove is doing something wrong here: I believe wordpress_path: "/Users/me/Local Sites/***/app/public/" is valid .yml syntax. So I passed the path /Users/me/Local Sites/***/app/public/ correctly to wordmove. It is now up to wordmove to correctly pass that path to other programs/components itself might use!

alessandro-fazzi commented 2 years ago

From a theoretical point of view, I'm totally with you.

Always hoped various things:

I've updated wiki's doc warning about this misbehaviour. I'm sure this is better than nothing 👍

Thanks for your comprehension.