現象
Vagrantfileにてプロビジョニングにシェルスクリプトファイルを設定し、vagrant up
を実行すると、下記のようなメッセージが表示される場合があります。
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/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.3/plugins/provisioners/shell/provisioner.rb:88:in `with_script_file' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/plugins/provisioners/shell/provisioner.rb:20:in `provision' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/builtin/provision.rb:89:in `run_provisioner' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:95:in `call' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:95:in `block in finalize_action' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.4.3/lib/vagrant/action/warden.rb:34:in `call'
なんかプロビジョニングで失敗しているなぁ~と思って調べてみました。
原因
このようなエラーが発生するシェルスクリプトファイルの例を示します。
#!/bin/sh echo "hello!" #にほんごです。
つまり、スクリプト内に日本語を含めてしまうと、上記のようなエラーが発生します。
解決法
一番安全な方法としては、シェルスクリプトに日本語を含めないことではないでしょうか。
なお、こちらで紹介されている方法(エンコードを指定する)ではエラーは解消されませんでした。
参考
vagrant upでgsub!: invalid byte sequence in Windows-31J (ArgumentError) - DQNEO起業日記