Bugs item #28212, was opened at 2010-05-18 08:36
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=575&aid=28212&group_id=126
Category: #gem and #require methods
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Mike Smith (msmith177)
>Assigned to: John Barnette (jbarnette)
Summary: UndefinedConversionError if Encoding.default_internal=ASCII-8BIT
Initial Comment:
With ruby 1.9.1, the default internal string encoding can be set with
Encoding.default_internal= or by passing ruby the -E":US-ASCII" option.
If the internal encoding is set to non-UTF-8 encodings such as US-ASCII,
BINARY, or ISO-8859-1, then you will get an exception when trying to load
rubygems if you have installed gemspecs that have non-ASCII characters.
==== To reproduce ====
* Install Nokogiri, or any other gem that has non-ascii characters in its
gemspec.
* Run test.rb (attached)
==== Exception ====
$ ruby test.rb
Encoding.default_internal = US-ASCII
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/source_index.rb:89:in `read':
"\xE9\x8B\xB8" from UTF-8 to US-ASCII (Encoding::UndefinedConversionError)
from
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/source_index.rb:89:in
`load_specification'
from
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/source_index.rb:153:in `block
(2 levels) in load_gems_in'
from
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/source_index.rb:152:in `each'
from
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/source_index.rb:152:in `block
in load_gems_in'
from
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/source_index.rb:149:in
`reverse_each'
from
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/source_index.rb:149:in
`load_gems_in'
from
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/source_index.rb:345:in
`refresh!'
from
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/source_index.rb:78:in
`from_gems_in'
from
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/source_index.rb:58:in
`from_installed_gems'
from /opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems.rb:883:in
`source_index'
from
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/gem_path_searcher.rb:81:in
`init_gemspecs'
from
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/gem_path_searcher.rb:13:in
`initialize'
from /opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems.rb:841:in `new'
from /opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems.rb:841:in `block
in searcher'
from <internal:prelude>:8:in `synchronize'
from /opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems.rb:840:in
`searcher'
from /opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems.rb:479:in
`find_files'
from /opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems.rb:983:in
`load_plugins'
from /opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems.rb:1139:in `<top
(required)>'
from <internal:gem_prelude>:235:in `require'
from <internal:gem_prelude>:235:in `load_full_rubygems_library'
from <internal:gem_prelude>:334:in `const_missing'
from test.rb:12:in `<main>'
==== Suggested fix ====
Always specify the internal encoding as UTF-8 when reading gemspec files.
Don't use the default internal encoding. (see attached patch)
==== My environment ====
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.1 (2010-01-10 patchlevel 378) [i386-darwin10]
- INSTALLATION DIRECTORY: /opt/local/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /opt/local/bin/ruby1.9
- EXECUTABLE DIRECTORY: /opt/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-10
- GEM PATHS:
- /opt/local/lib/ruby/gems/1.9.1
- /Users/msmith/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
----------------------------------------------------------------------
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=575&aid=28212&group_id=126
_______________________________________________
Rubygems-developers mailing list
http://rubyforge.org/projects/rubygems
[email protected]
http://rubyforge.org/mailman/listinfo/rubygems-developers