vagrant icon indicating copy to clipboard operation
vagrant copied to clipboard

Encoding::UndefinedConversionError on vagrant up

Open arturbanul opened this issue 4 years ago • 20 comments

I saw that issue was reported before and it's closed now but suddenly I'm getting this error again on windows 10:

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

I upgraded to Vagrant 2.2.14 but this problem was on previous version 2.2.8.

arturbanul avatar Dec 28 '20 12:12 arturbanul

It works with vagrant version 2.2..6 although I had to downgrade VirtualBox to 6.0.4.

Windows 10 version: image

So starting from vagrant version 2.2.8 I have this error.

arturbanul avatar Dec 29 '20 10:12 arturbanul

@arturbanul 这个问题你解决了吗 我今天和你遇到的问题一样 不知道问题出现在哪里 安装路径中没有中文的路径

phpSign110 avatar Mar 12 '21 10:03 phpSign110

@phpSign110 As I remember I changed python to some previous version and it started to work. Kind of workaround.

arturbanul avatar Mar 12 '21 12:03 arturbanul

I had the same issue and solved it today. (14.03.2021) You should go to "C:\HashiCorp\Vagrant\embedded\gems\2.2.14\gems\vagrant-2.2.14\bin" address and open "vagrant" file. At the beginning of the file, you will see "#!/usr/bin/env ruby" Paste the below 2 lines after this first line.

Encoding.default_external = Encoding.find('Windows-1251')
Encoding.default_internal = Encoding.find('Windows-1251')

Be careful, they are "1251", not "1250". Solved. :)

m4h1r avatar Mar 15 '21 00:03 m4h1r

I'm having the exact same error on a fresh install.

@m4h1r fix did not work for me.

Edit: downgrading to vagrant 2.2.6 and vbox 6.0.24 works.

RosayGaspard avatar Mar 24 '21 08:03 RosayGaspard

@RosayGaspard I was going to ask you to check the version. But I believe you solved with version downgrading.

m4h1r avatar Mar 24 '21 10:03 m4h1r

@m4h1r what will be chcp command output in cmd and powershell on your end?

ps. in my case I had to rollback the following commit https://github.com/enkessler/childprocess/commit/0230cf96ce2fb15eb7c9538b14d75f7b50f3e505

avoidik avatar Apr 09 '21 15:04 avoidik

@m4h1r what will be chcp command output in cmd and powershell on your end?

ps. in my case I had to rollback the following commit enkessler/childprocess@0230cf9

I got it on Git Bash.

m4h1r avatar Apr 10 '21 16:04 m4h1r

have you tried on Windows Terminal?

avoidik avatar Apr 10 '21 17:04 avoidik

No, I use mostly use Git Bash for everything.

m4h1r avatar Apr 10 '21 18:04 m4h1r

I had the same issue and solved it today. (14.03.2021) You should go to "C:\HashiCorp\Vagrant\embedded\gems\2.2.14\gems\vagrant-2.2.14\bin" address and open "vagrant" file. At the beginning of the file, you will see "#!/usr/bin/env ruby" Paste the below 2 lines after this first line.

Encoding.default_external = Encoding.find('Windows-1251')
Encoding.default_internal = Encoding.find('Windows-1251')

Be careful, they are "1251", not "1250". Solved. :)

thanks! It works for me

yclgkd avatar Apr 22 '21 09:04 yclgkd

Having similar problem: C:/HashiCorp/Vagrant/embedded/gems/2.2.16/gems/childprocess-4.0.0/lib/childprocess/windows/process_builder.rb:44:in 'encode!': "\xD0" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to UTF-16LE (Encoding::UndefinedConversionError)

Encoding.default_external = Encoding.find('Windows-1251') Encoding.default_internal = Encoding.find('Windows-1251')

Doesn't work for me.

vichvich4444 avatar May 19 '21 15:05 vichvich4444

Having similar problem: C:/HashiCorp/Vagrant/embedded/gems/2.2.16/gems/childprocess-4.0.0/lib/childprocess/windows/process_builder.rb:44:in 'encode!': "\xD0" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to UTF-16LE (Encoding::UndefinedConversionError)

Encoding.default_external = Encoding.find('Windows-1251') Encoding.default_internal = Encoding.find('Windows-1251')

Doesn't work for me.

Have the same issue on PowerShell. Was able to avoid it by using "cmd" instead.

Trimod avatar May 25 '21 08:05 Trimod

Can confirm switching from Windows Terminal to cmd cleared the error,

zmaniacz avatar May 31 '21 16:05 zmaniacz

I'm using Windows Terminal, with rolled back https://github.com/enkessler/childprocess/commit/0230cf96ce2fb15eb7c9538b14d75f7b50f3e505

avoidik avatar May 31 '21 17:05 avoidik

How does one vote for a bug report? Thumbs up? Thumbs down? ;) In any case, I also ran into this issue: fresh Vagrant 2.2.16 install, first command from the quickstart (vagrant init hashicorp/bionic64).

skrysmanski avatar Jun 11 '21 13:06 skrysmanski

So I did some more digging. Even simple commands like vagrant --help produce this error. I also tried to use cmd (instead of Windows Terminal) but I'm getting the same error there.

Since this seems to be a bug in enkessler/childprocess, maybe @sds can shed some light onto this issue? (I myself am not a Ruby developer so I wouldn't even know where start looking.)

skrysmanski avatar Jun 13 '21 06:06 skrysmanski

encountered this in a "git bash" shell, opened a "Command Prompt" window instead and did a vagrant init in there and it worked fine.

kenguest avatar Jun 22 '21 09:06 kenguest

Can confirm switching from Windows Terminal to cmd cleared the error,

In my case, it was just enough to switch to the "Command Prompt" profile within the Windows Terminal.

shupoval avatar Mar 31 '22 15:03 shupoval

Adding a possible solution to this problem as a Chinese user: make sure the installation path doesn't have any Chinese characters! This may also work for users of other languages such as Russian, Thai, Japanese, etc. Make sure that the path is in English only.

MrZoyo avatar Jun 01 '22 11:06 MrZoyo