Issue #17010 has been updated by Josh Cooper. Target version set to 3.0.x Affected Puppet version set to 3.0.0
I believe this is a bug in the `win32/dir` gem in that it should be returning a string whose encoding is `Encoding.ascii_compatible?` rather than UTF-16LE. >From ><https://groups.google.com/d/topic/ruby-core-google/aiW7jRNWRvk/discussion>: <pre> |> Does anyone have information as to the current status of |> adding Unicode-savvy path handling to 1.9 ruby? | |Ugh. Sorry, I mean of course: Unicode-savvy path handling |on *win32* ruby 1.9. Every path encoding is UTF-8 and converted to UTF-16 internally. If there's something still use *A functions, it will eventually replaced by *W functions. In short, if you're using UTF-8 for your program encoding, you should not see any problem (if you do, it's a bug). matz. </pre> The ruby 1.9.3 source also has native code for resolving windows special folders. It calls the *W version of SHGetSpecialFolderLocation: <pre> static BOOL get_special_folder(int n, WCHAR *env) { LPITEMIDLIST pidl; LPMALLOC alloc; BOOL f = FALSE; if (SHGetSpecialFolderLocation(NULL, n, &pidl) == 0) { ... </pre> And converts the wchar_t string using the current filesystem encoding: <pre> VALUE rb_w32_special_folder(int type) { WCHAR path[_MAX_PATH]; if (!get_special_folder(type, path)) return Qnil; regulate_path(path); return rb_w32_conv_from_wchar(path, rb_filesystem_encoding()); } </pre> Okay, it turns out we can eliminate the need for `win32/dir` in ruby 1.9.3: <pre> irb(main):023:0> require 'etc' irb(main):026:0> Etc.sysconfdir => "C:/ProgramData" irb(main):027:0> Etc.sysconfdir.encoding => #<Encoding:Windows-1252> </pre> But those methods are not available in ruby 1.8.7, so we'll need to fall back to `win32/dir` <pre> C:\work\puppet>irb irb(main):001:0> require 'etc' => false irb(main):002:0> Etc.sysconfdir NoMethodError: undefined method `sysconfdir' for Etc:Module from (irb):2 </pre> ---------------------------------------- Bug #17010: Puppet 3.0 - Windows - Char Encoding Path Problem https://projects.puppetlabs.com/issues/17010#change-73789 Author: Ed Sumerfield Status: Accepted Priority: Normal Assignee: Category: Target version: 3.0.x Affected Puppet version: 3.0.0 Keywords: 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 `<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 `<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 post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
