Zach Adams Web Developer and Programmer

Invalid byte sequence in UTF-8 fix for Wordmove

September 18, 2014


If you guys use Wordmove and just so happen to run into this very annoying error anytime you try to push or pull from a database here’s what I did to fix it.

Edit: I have also noticed a distinct dislike for the Wordfence Security plugin by Wordmove, removing the plugin Wordfence and deleting the tables starting with wF in your database might fix your issue.

For the record this is the full error:

/var/lib/gems/2.1.0/gems/wordmove-1.2.0/lib/wordmove/sql_adapter.rb:47:in `gsub!': invalid byte sequence in UTF-8 (ArgumentError)
 from /var/lib/gems/2.1.0/gems/wordmove-1.2.0/lib/wordmove/sql_adapter.rb:47:in `serialized_replace!'
 from /var/lib/gems/2.1.0/gems/wordmove-1.2.0/lib/wordmove/sql_adapter.rb:36:in `replace_field!'
 from /var/lib/gems/2.1.0/gems/wordmove-1.2.0/lib/wordmove/sql_adapter.rb:25:in `replace_vhost!'
 from /var/lib/gems/2.1.0/gems/wordmove-1.2.0/lib/wordmove/sql_adapter.rb:17:in `adapt!'
 from /var/lib/gems/2.1.0/gems/wordmove-1.2.0/lib/wordmove/deployer/base.rb:182:in `adapt_sql'
 from /var/lib/gems/2.1.0/gems/wordmove-1.2.0/lib/wordmove/deployer/ssh.rb:35:in `pull_db'
 from /var/lib/gems/2.1.0/gems/wordmove-1.2.0/lib/wordmove/cli.rb:47:in `block in pull'
 from /var/lib/gems/2.1.0/gems/wordmove-1.2.0/lib/wordmove/cli.rb:34:in `block in handle_options'
 from /var/lib/gems/2.1.0/gems/wordmove-1.2.0/lib/wordmove/cli.rb:32:in `each'
 from /var/lib/gems/2.1.0/gems/wordmove-1.2.0/lib/wordmove/cli.rb:32:in `handle_options'
 from /var/lib/gems/2.1.0/gems/wordmove-1.2.0/lib/wordmove/cli.rb:46:in `pull'
 from /var/lib/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
 from /var/lib/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
 from /var/lib/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
 from /var/lib/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
 from /var/lib/gems/2.1.0/gems/wordmove-1.2.0/bin/wordmove:6:in `<top (required)>'
 from /usr/local/bin/wordmove:23:in `load'
 from /usr/local/bin/wordmove:23:in `<main>'

Update, I found a better solution, leaving the old one below the <hr> tag:

Add the following lines to line 44 just about the gsub of /var/lib/gems/2.1.0/gems/wordmove-1.2.0/lib/wordmove/sql_adapter.rb or /Library/Ruby/Gems/2.0.0/gems/wordmove-1.2.0/lib/wordmove/sql_adapter.rb if you’re OSX

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


That should fix the issue completely!


@schurig from Github reports that adding the following line:


Just above the gsub in the following file:


Fixes the issue for him. If this fixes the issue for you awesome, but I still continued to have the error, so here’s what I had to do.

Go into your database and find any tables not using the collation utf8_general_ci and change them to that.

After using both those fixes it started working for me.