Bug #8508

Invalid byte sequence in UTF-8 (ArgumentError) in win32/registry.rb

Added by Thomas Deinhamer 11 months ago. Updated 26 days ago.

[ruby-core:55393]
Status:Closed
Priority:Normal
Assignee:cruby-windows
Category:M17N
Target version:-
ruby -v:1.9.3 Backport:1.9.3: REQUIRED, 2.0.0: REQUIRED

Description

Hi guys!

I'm using Vagrant and the VMware workstation plugin to provision a VMware workstation VM
but in the end this doesn't work because I get an error in win32/registry.rb:

"C:/HashiCorp/Vagrant/embedded/lib/ruby/1.9.1/win32/registry.rb:173:in `tr': invalid byte sequence in UTF-8 (ArgumentError)"

The Vagrant debug log which includes the error trace can be found here:
https://gist.github.com/thasmo/12f88c7b1025aa5f2c32

The related Vagrant bug ticket can be found here:
https://github.com/mitchellh/vagrant/issues/1757#issuecomment-19175619

Please let me know if you need any further information on this!

Thanks a lot!

Associated revisions

Revision 41838
Added by Nobuyoshi Nakada 10 months ago

win32/registry.rb: use WCHAR

  • ext/dl/win32/lib/win32/registry.rb (Error, API): use WCHAR interfaces. c.f. [Bug #8508]

History

#1 Updated by Nobuyoshi Nakada 10 months ago

  • Category changed from platform/windows to M17N
  • Status changed from Open to Feedback
  • ruby -v changed from 1.9.1 to 1.9.3

That line in 1.9.1 is a comment, so it would be 1.9.3.

But why is Encoding.locale_charmap UTF-8 on Windows?
Are you using codepage 65001?

#2 Updated by Thomas Deinhamer 10 months ago

Hi there!

Line 173 in the registry.rb file here on my PC is this one:
super msg.tr("\r", '').chomp

I'm sorry, I don't know how to set locale_charmap
and I'm not sure what a codepage is.

I'm running the App (Vagrant) using Cygwin on the mintty.exe terminal.

If you wanna tell me how to find out the codepage I can provide you with that info.

Thank you!

#3 Updated by Thomas Deinhamer 10 months ago

It actually seems this only happens when using Cygwin with the mintty.exe terminal.
Any idea how to solve this?

#4 Updated by Thomas Deinhamer 10 months ago

And btw. "chcp" gives me:
Aktive Codepage: 850.

#5 Updated by Yui NARUSE 10 months ago

I'm running the App (Vagrant) using Cygwin on the mintty.exe terminal.

It sounds root cause.

And btw. "chcp" gives me:
Aktive Codepage: 850.

Thanks.
Could you show following result?
ruby -e'puts Encoding.locale_charmap'

#6 Updated by Thomas Deinhamer 10 months ago

'ruby' is not installed in my Cygwin environment, but Vagrant
has an embedded version of ruby so I ran the command using it.

cd /cygdrive/c/HashiCorp/Vagrant/embedded/bin
./ruby.exe -e'puts Encoding.locale_charmap'

Which gives the output: UTF-8

Not sure if this is the right way to test it.

With this result is it possible to
guess what the cause of the error is?

Can I do anything else to get
this fixed? Just let me know!

#7 Updated by Thomas Deinhamer 10 months ago

So it seems to be a problem with the used shell,
not the terminal. I've now tried Console2 running
the default Windows shell and the ZSH shell from the
Cygwin environment and using the Windows shell it
works, but using ZSH/Cygwin it throws the error.

Executing this: /cygdrive/c/HashiCorp/Vagrant/embedded/bin/ruby.exe --version
gives me: ruby 1.9.3p392 (2013-02-22) [i386-mingw32]

If I comment out line 172 it works.

msg = msg[0, len].forceencoding(Encoding.find(Encoding.localecharmap))

I've also found some guy having similar problems (I think):
http://www.microsofttranslator.com/bv.aspx?from=&to=de&a=http%3A%2F%2Fwiki.livedoor.jp%2Fkou1okada%2Fd%2FCygwin%2520-%2520Ruby-1.9.3p327%2520-%2520win32%2Fregistry
So not sure if that's related to this encoding problem.

#8 Updated by Nobuyoshi Nakada 10 months ago

  • Status changed from Feedback to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r41838.
Thomas, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


win32/registry.rb: use WCHAR

  • ext/dl/win32/lib/win32/registry.rb (Error, API): use WCHAR interfaces. c.f. [Bug #8508]

#9 Updated by Thomas Deinhamer 9 months ago

Perfect. Thank you for responding, really
appreciate it! Keep up the good work! :)

#10 Updated by Thomas Deinhamer 9 months ago

Is there any roadmap where I could find
out when this fix is gonna be available
with the release of a new ruby version?

#11 Updated by Eric Hodel 26 days ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: REQUIRED, 2.0.0: REQUIRED

Add backport request

Also available in: Atom PDF