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

DB pull fails with an JSON::ParserError error #654

Closed w33zy closed 1 year ago

w33zy commented 2 years ago

Describe the bug

When running WM with the wordmove pull --db command the process fails with an JSON::ParserError error.

Wordmove command

wordmove pull --db

Expected behavior

The process to complete without error.

Exception/trace

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

    local | mysqldump --host=[secret] --user=root --password=[secret] --result-file="[secret]/wp-content/local-backup-1653235329.sql" website_com_db

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

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

   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=root --password=[secret] --database=website_com_db --execute="SET autocommit=0;SOURCE [secret]/wp-content/dump.sql;COMMIT"

    local | adapt dump for vhost
Error: YIKES! It looks like you're running this as root. You probably meant to run this as the user that your WordPress installation exists under.

If you REALLY mean to run this as root, we won't stop you, but just bear in mind that any code on this site will then have full control of your server, making it quite DANGEROUS.

If you'd like to continue as root, please run this again, adding this flag:  --allow-root

If you'd like to run it as the user that this site is under, you can run the following to become the respective user:

    sudo -u USER -i -- wp <command>

Traceback (most recent call last):
        21: from /usr/local/rvm/gems/ruby-2.7.2/bin/ruby_executable_hooks:22:in `<main>'
        20: from /usr/local/rvm/gems/ruby-2.7.2/bin/ruby_executable_hooks:22:in `eval'
        19: from /usr/local/rvm/gems/ruby-2.7.2/bin/wordmove:23:in `<main>'
        18: from /usr/local/rvm/gems/ruby-2.7.2/bin/wordmove:23:in `load'
        17: from /usr/local/rvm/gems/ruby-2.7.2/gems/wordmove-5.2.2/exe/wordmove:6:in `<top (required)>'
        16: from /usr/local/rvm/gems/ruby-2.7.2/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
        15: from /usr/local/rvm/gems/ruby-2.7.2/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        14: from /usr/local/rvm/gems/ruby-2.7.2/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        13: from /usr/local/rvm/gems/ruby-2.7.2/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        12: from /usr/local/rvm/gems/ruby-2.7.2/gems/wordmove-5.2.2/lib/wordmove/cli.rb:91:in `pull'
        11: from /usr/local/rvm/gems/ruby-2.7.2/gems/wordmove-5.2.2/lib/wordmove/cli.rb:39:in `handle_options'
        10: from /usr/local/rvm/gems/ruby-2.7.2/gems/wordmove-5.2.2/lib/wordmove/cli.rb:39:in `each'
         9: from /usr/local/rvm/gems/ruby-2.7.2/gems/wordmove-5.2.2/lib/wordmove/cli.rb:40:in `block in handle_options'
         8: from /usr/local/rvm/gems/ruby-2.7.2/gems/wordmove-5.2.2/lib/wordmove/cli.rb:92:in `block in pull'
         7: from /usr/local/rvm/gems/ruby-2.7.2/gems/wordmove-5.2.2/lib/wordmove/deployer/ssh.rb:48:in `pull_db'
         6: from /usr/local/rvm/gems/ruby-2.7.2/gems/wordmove-5.2.2/lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb:37:in `adapt_remote_db!'
         5: from /usr/local/rvm/gems/ruby-2.7.2/gems/wordmove-5.2.2/lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb:50:in `wpcli_search_replace'
         4: from /usr/local/rvm/gems/ruby-2.7.2/gems/wordmove-5.2.2/lib/wordmove/sql_adapter/wpcli.rb:19:in `command'
         3: from /usr/local/rvm/gems/ruby-2.7.2/gems/wordmove-5.2.2/lib/wordmove/sql_adapter/wpcli.rb:38:in `cli_config_path'
         2: from /usr/local/rvm/gems/ruby-2.7.2/gems/wordmove-5.2.2/lib/wordmove/sql_adapter/wpcli.rb:49:in `load_from_cli'
         1: from /usr/local/rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/json/common.rb:156:in `parse'
/usr/local/rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/json/common.rb:156:in `parse': 783: unexpected token at '' (JSON::ParserError)

Environment (please complete the following information):

Doctor

All green.

w33zy commented 2 years ago

Also, I was able to complete the process by using the default DB adapter

alessandro-fazzi commented 2 years ago

Hi @w33zy , do you maybe have a wp-cli.yml file somewhere in your project?

w33zy commented 2 years ago

Hello @pioneerskies it appears I do not have that file on my server. Running wp version --debug gives the below result:

Debug (bootstrap): No readable global config found (0.061s)
Debug (bootstrap): No project config found (0.061s)
Debug (bootstrap): argv: /usr/local/bin/wp version --debug (0.061s)
alessandro-fazzi commented 2 years ago

WM parses the JSON produced by this wp-cli command:

wp cli param-dump --with-values

and it is trying to access the key as reported in this img

immagine

Would you mind to try for the same operation? I cannot imagine how the JSON shuold turn out invalid from there :/ and maybe this could give a clue.

w33zy commented 2 years ago

Here is the output from my server

Screenshot 2022-05-30 082603
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.