vagrant upでgsub!: invalid byte sequence in Windows-31J (ArgumentError)

Vagrantでshellscriptによるprovisionをしようとしたらエラーが出ました。

[default] Running cleanup tasks for 'shell' provisioner...
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.2/plugins/provisioners/shell/provisioner.rb:88:in `gsub!': invalid byte sequence in Windows-31J (ArgumentError)
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.2/plugins/provisioners/shell/provisioner.rb:88:in `with_script_file'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.2/plugins/provisioners/shell/provisioner.rb:20:in `provision'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.2/lib/vagrant/action/builtin/provision.rb:89:in `run_provisioner'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.2/lib/vagrant/action/warden.rb:95:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.2/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.2/lib/vagrant/action/warden.rb:34:in `call'

対処法

Vagrantfileの中で"Encoding.default_external = 'UTF-8'"と記述したら解消されました。
仕組みはよくわかっていません><
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  ...
  Encoding.default_external = 'UTF-8'

  config.vm.provision "shell" , path: "setup.sh"
  ...
end
参考
invalid byte sequence in Windows-31J が出たときは
カテゴリ: