welaika / wordmove

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

i have the error of "default.rb:45:in `gsub!': invalid byte sequence in UTF-8 (ArgumentError)" #398

Closed byron222 closed 7 years ago

byron222 commented 7 years ago

i try many things but still have this error.

/root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/wordmove-2.1.2/lib/wordmove/sql_adapter/default.rb:45:in gsub!': invalid byte sequence in UTF-8 (ArgumentError) from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/wordmove-2.1.2/lib/wordmove/sql_adapter/default.rb:45:inserialized_replace!' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/wordmove-2.1.2/lib/wordmove/sql_adapter/default.rb:38:in replace_field!' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/wordmove-2.1.2/lib/wordmove/sql_adapter/default.rb:26:inreplace_vhost!' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/wordmove-2.1.2/lib/wordmove/sql_adapter/default.rb:18:in adapt!' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/wordmove-2.1.2/lib/wordmove/deployer/ssh/default_sql_adapter.rb:42:inadapt_sql' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/wordmove-2.1.2/lib/wordmove/deployer/ssh/default_sql_adapter.rb:30:in adapt_remote_db!' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/wordmove-2.1.2/lib/wordmove/deployer/ssh.rb:35:inpull_db' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/wordmove-2.1.2/lib/wordmove/cli.rb:69:in block in pull' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/wordmove-2.1.2/lib/wordmove/cli.rb:37:inblock in handle_options' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/wordmove-2.1.2/lib/wordmove/cli.rb:36:in each' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/wordmove-2.1.2/lib/wordmove/cli.rb:36:inhandle_options' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/wordmove-2.1.2/lib/wordmove/cli.rb:68:in pull' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/command.rb:27:inrun' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in invoke_command' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor.rb:369:indispatch' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/base.rb:444:in start' from /root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/wordmove-2.1.2/exe/wordmove:6:in<top (required)>' from /root/.rbenv/versions/2.4.1/bin/wordmove:22:in load' from /root/.rbenv/versions/2.4.1/bin/wordmove:22:in

'

alessandro-fazzi commented 7 years ago

This is a known limitation, but we possibly have some good news.

Please read more about problem and approaches at https://github.com/welaika/wordmove/wiki/invalid-byte-sequence-in-UTF-8-while-pushing---pulling-db/_edit#use-sqladapterwpcli-experimental

byron222 commented 7 years ago

so, there is nothing i can do?

because i already try this

1) Modified/created a~/.profile' 2) added these two lines to .profile:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

3) source your ~/.profile

source ~/.profile `

And nothing change.....

byron222 commented 7 years ago

ok, i fix this!

i add

sql_content.encode!('UTF-16', 'UTF-8', :invalid => :replace, :replace => '')
sql_content.encode!('UTF-8', 'UTF-16')
sql_content.force_encoding("UTF-8")

to this File,above the line 45

/root/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/wordmove-2.1.2/lib/wordmove/sql_adapter/default.rb

alessandro-fazzi commented 7 years ago

Dear @byron222,

I assume you haven't read the solution to use wpcli as SqlAdapter described in the wiki page I posted.

Up to you, but keep in mind that approach could corrupt your data. We wrote a specific disclaimer about the choice to not implement such a risky code.

The new SqlAdapter is intended primarily to overcome this kind of problem.

Bye