Issue #17010 has been updated by Josh Cooper.

Status changed from Accepted to Closed

I can no longer reproduce this problem:

<pre>
C:\ruby193\bin>ruby --version
ruby 1.9.3p392 (2013-02-22) [i386-mingw32]
C:\ruby193\bin>irb
irb(main):001:0> require 'win32/dir'
=> true
irb(main):002:0> Dir::WINDOWS.encoding
=> #&lt;Encoding:US-ASCII>
irb(main):003:0> Dir::WINDOWS.encoding.ascii_compatible?
=> true
irb(main):004:0> require 'rspec-puppet'
=> true
</pre>

<pre>
C:\>gem list

*** LOCAL GEMS ***

bigdecimal (1.1.0)
columnize (0.3.6)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.2.0)
diff-lcs (1.2.3)
ffi (1.7.0 x86-mingw32)
io-console (0.3)
json (1.5.5)
metaclass (0.0.1)
minitar (0.5.4)
minitest (2.5.1)
mocha (0.13.3)
puppetlabs_spec_helper (0.4.1)
rake (0.9.2.2)
rdoc (3.9.5)
rgen (0.6.2)
rspec (2.13.0)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
rspec-mocks (2.13.1)
rspec-puppet (0.1.6)
stomp (1.2.9)
sys-admin (1.5.6 x86-mingw32)
win32-api (1.4.8 x86-mingw32)
win32-dir (0.3.7)
win32-eventlog (0.5.3)
win32-process (0.6.5)
win32-security (0.1.4)
win32-service (0.7.2 x86-mingw32)
win32-taskscheduler (0.2.2)
win32console (1.3.2 x86-mingw32)
windows-api (0.4.2)
windows-pr (1.2.2)
</pre>

Ed, can you try the latest 3.2 RC1? If the issue still persists, please reopen 
the ticket.

----------------------------------------
Bug #17010: win32-dir gem returns a string whose encoding is not 
`ascii_compatible?`
https://projects.puppetlabs.com/issues/17010#change-89652

* Author: Ed Sumerfield
* Status: Closed
* Priority: Normal
* Assignee: Josh Cooper
* Category: 
* Target version: 3.x
* Affected Puppet version: 3.0.0
* Keywords: windows
* Branch: 
----------------------------------------
Problem originally defined by this exception:

<pre>
: irb
irb(main):001:0> require "rspec-puppet"
Failed to load feature test for root: uninitialized constant 
Windows::Synchronize
ArgumentError: string contains null byte
        from 
C:/ruby193/lib/ruby/gems/1.9.1/gems/puppet-3.0.0/lib/puppet/util/run_mode.rb:67:in
 `join'
        from 
C:/ruby193/lib/ruby/gems/1.9.1/gems/puppet-3.0.0/lib/puppet/util/run_mode.rb:67:in
 `conf_dir'
        from 
C:/ruby193/lib/ruby/gems/1.9.1/gems/puppet-3.0.0/lib/puppet/settings.rb:495:in 
`user_config_file'
        from 
C:/ruby193/lib/ruby/gems/1.9.1/gems/puppet-3.0.0/lib/puppet/settings.rb:1234:in 
`which_configuration_file'
        from 
C:/ruby193/lib/ruby/gems/1.9.1/gems/puppet-3.0.0/lib/puppet/settings.rb:475:in 
`parse_config_files'
        from 
C:/ruby193/lib/ruby/gems/1.9.1/gems/puppet-3.0.0/lib/puppet/settings.rb:147:in 
`initialize_global_settings'

        from 
C:/ruby193/lib/ruby/gems/1.9.1/gems/puppet-3.0.0/lib/puppet.rb:135:in 
`do_initialize_settings_for_run_mode'

        from 
C:/ruby193/lib/ruby/gems/1.9.1/gems/puppet-3.0.0/lib/puppet.rb:123:in 
`initialize_settings'
        from 
C:/ruby193/lib/ruby/gems/1.9.1/gems/rspec-puppet-0.1.5/lib/rspec-puppet.rb:10:in
 `&lt;top (required)>'
        from 
C:/ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
        from 
C:/ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in 
require'
        from 
C:/ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
        from (irb):1
        from C:/ruby193/bin/irb:12:in `&lt;main>'
</pre>

Research concluded that ruby 1.9.3 does not support File.join of strings that 
are not UTF-8.  There is a ruby fix associated with this problem mentioned here:

<https://bugs.ruby-lang.org/issues/7168>

Since this fix is not useful for 1.9.3 the following patch is a possible way 
around it.

<pre>
class File
  class << self
    alias_method :original_join, :join
  end

  def self.join(*args)
    new_args = args.collect { |questionableEncoding|
      join_encoding_fix(questionableEncoding)
    }
    self.send(:original_join, new_args)
  end

  def self.join_encoding_fix(value)
    if (value.instance_of?(String))
      value = value.encode("UTF-8")
    elsif (value.instance_of?(Array))
      value = value.collect { |subValue|
        join_encoding_fix(subValue)
      }
    end
    value
  end
end
</pre>


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to