Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ruby 2.0: .../lib/veewee/provider/vmfusion/provider.rb:34:in `split': invalid byte sequence in US-ASCII (ArgumentError) #741

Closed
offby1 opened this issue Jun 25, 2013 · 2 comments

Comments

@offby1
Copy link
Contributor

offby1 commented Jun 25, 2013

I tried to build a VMware box, with ruby 2.0, and got the above exception.

I suspect the problem is due to non-ASCII characters (the copyright symbol (c) for one) in the output of ``system_profiler SPApplicationsDataType'', combined with changes to the default encoding of streams in ruby 1.9+.

This little snippet demonstrates the problem:

shell_results = IO.popen("system_profiler SPApplicationsDataType"){ |p| p.readlines }
shell_results.join('').split(/VMware/)

/usr/bin/ruby (i.e., ruby 1.8) runs this with no problem, but ruby 1.9 and 2.0 die with the exception.

Changing the script allows it to run on the newer rubies:

shell_results = IO.popen("system_profiler SPApplicationsDataType",
                         :external_encoding => Encoding::UTF_8){ |p| p.readlines }
shell_results.join('').split(/VMware/)

... but then it breaks on 1.8, because there is no Encoding module. If I had more ruby-fu, I'd find a way to test, at runtime, for the presence of the Encoding module, and only pass that :external_encoding option if it were present.

@n0ts
Copy link
Contributor

n0ts commented Oct 3, 2014

Hi, I got a same issue.
I send a pull-request https://github.com/jedi4ever/veewee/pull/986/files
Thanks!

@mpapis
Copy link
Collaborator

mpapis commented Oct 3, 2014

fixed with #986

@mpapis mpapis closed this as completed Oct 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants