1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

VagrantでEncoding::UndefinedConversionErrorを食らった時の解決策

Posted at

環境

  • OS : Windows10 Pro バージョン 2004(OSビルド 19041.572)
  • 端末? : Git for Windows (GitBash) version 2.29.2.2
  • vagrant : version 2.2.13
  • virtualbox : バージョン 6.1.16 r140961 (Qt5.6.2)

結論

端末の文字セットをSJIS(Shift-JIS)にして再ログイン。

。。。

ちょっとだけ詳しく

久々にvagrantを使おうと思いvagrant initしたら以下のエラーに遭遇。

$ vagrant init
C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/childprocess-4.0.0/lib/childprocess/windows/process_builder.rb:44:in `encode!': "\xE7" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to UTF-16LE (Encoding::UndefinedConversionError)
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/childprocess-4.0.0/lib/childprocess/windows/process_builder.rb:44:in `to_wide_string'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/childprocess-4.0.0/lib/childprocess/windows/process_builder.rb:67:in `create_environment_pointer'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/childprocess-4.0.0/lib/childprocess/windows/process_builder.rb:28:in `start'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/childprocess-4.0.0/lib/childprocess/windows/process.rb:70:in `launch_process'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/childprocess-4.0.0/lib/childprocess/abstract_process.rb:81:in `start'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/util/subprocess.rb:155:in `block in execute'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/util/safe_chdir.rb:26:in `block (2 levels) in safe_chdir'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/util/safe_chdir.rb:25:in `chdir'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/util/safe_chdir.rb:25:in `block in safe_chdir'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/util/safe_chdir.rb:24:in `synchronize'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/util/safe_chdir.rb:24:in `safe_chdir'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/util/subprocess.rb:154:in `execute'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/util/subprocess.rb:22:in `execute'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/util/powershell.rb:174:in `version'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/util/powershell.rb:195:in `validate_install!'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/util/powershell.rb:96:in `execute_cmd'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/util/platform.rb:82:in `block in windows_admin?'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/util/platform.rb:84:in `windows_admin?'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/plugins/providers/hyperv/provider.rb:20:in `usable?'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/environment.rb:361:in `block in default_provider'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/registry.rb:49:in `block in each'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/registry.rb:48:in `each'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/registry.rb:48:in `each'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/environment.rb:347:in `default_provider'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/environment.rb:943:in `guess_provider'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/environment.rb:955:in `find_configured_plugins'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/environment.rb:983:in `process_configured_plugins'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/environment.rb:178:in `initialize'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/bin/vagrant:168:in `new'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/bin/vagrant:168:in `<main>'

そこで、以下のことを試した。

  • Vagrantの再インストール
  • 日本語で命名されたディレクトリやファイルがカレント以下にないかの確認
  • Vagrantのコアファイルをいじる
  • 端末の文字セットをShift-JISにする

空のディレクトリでコマンドを打ったので日本語名のディレクトリなどはなかった。
再インストールしたてのVagrantのコアファイルをいじるのは避けたかった。

調べを進めた結果、端末側(GitBash)の文字セットをShift-JISにすることでエラーがなくなった。
(コアファイルをいじらずに済みました。)

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?