rnelson0 / puppet-generate-puppetfile

Generate or update a Puppetfile for use with r10k or librarian-puppet. Optionally, create a fixtures file for rspec-puppet.
92 stars 22 forks source link

Bug: invalid byte sequence in US-ASCII #48

Closed SamyCoenen closed 7 years ago

SamyCoenen commented 7 years ago

This is my error log:

<abs/code/environments/production/modules# generate-puppetfile -p ./Puppetfile

Installing modules. This may take a few minutes.

/opt/puppetlabs/puppet/lib/ruby/gems/2.1.0/gems/generate-puppetfile-0.10.0/lib/generate_puppetfile/bin.rb:222:in gsub!': invalid byte sequence in US-ASCII (ArgumentError) from /opt/puppetlabs/puppet/lib/ruby/gems/2.1.0/gems/generate-puppetfile-0.10.0/lib/generate_puppetfile/bin.rb:222:ingenerate_module_data' from /opt/puppetlabs/puppet/lib/ruby/gems/2.1.0/gems/generate-puppetfile-0.10.0/lib/generate_puppetfile/bin.rb:85:in run' from /opt/puppetlabs/puppet/lib/ruby/gems/2.1.0/gems/generate-puppetfile-0.10.0/bin/generate-puppetfile:6:in<top (required)>' from /opt/puppetlabs/puppet/bin/generate-puppetfile:23:in load' from /opt/puppetlabs/puppet/bin/generate-puppetfile:23:in

'

I've tried:

export LANG=en_US.UTF-8 export LANGUAGE=en_US.UTF-8 export LC_ALL=en_US.UTF-8

But the same issue remains.

The puppetfile should be fine because it works fine when executing with r10k: <ppetlabs/code/environments/production# r10k puppetfile install --verbose
INFO -> Updating module /etc/puppetlabs/code/environments/production/modules/zabbix INFO -> Updating module /etc/puppetlabs/code/environments/production/modules/chocolatey INFO -> Updating module /etc/puppetlabs/code/environments/production/modules/stdlib INFO -> Updating module /etc/puppetlabs/code/environments/production/modules/powershell INFO -> Updating module /etc/puppetlabs/code/environments/production/modules/windows_env

SamyCoenen commented 7 years ago

solved it with export RUBYOPT="-KU -E utf-8:utf-8"

rnelson0 commented 7 years ago

@SamyCoenen: thanks for the report and glad to see you fixed it! In case anyone else hits this, do you have any idea why that was needed for you?

SamyCoenen commented 7 years ago

Yes, this forces Ruby to use UTF-8 encoding. It might have something to do with my Ruby version:

in Ruby 1.9 the default is ASCII

in Ruby 2.0 the default is UTF-8.

When I do ruby -v I get this: ruby: warning: -K is specified; it is for 1.8 compatibility and may cause odd behavior ruby 2.1.9p490 (2016-03-30 revision 54437) [x86_64-linux]

rnelson0 commented 7 years ago

Interesting, I've not seen that before. Thanks for the extra information!