[Rubygems-developers] [ rubygems-Bugs-28154 ] Gem.binary_mode version test for Ruby 1.9 sets invalid rb:ascii-8bit mode

noreply at rubyforge.org noreply at rubyforge.org
Thu Apr 29 14:35:46 EDT 2010


Bugs item #28154, was opened at 2010-04-29 11:35
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=575&aid=28154&group_id=126

Category: other
Group: v1.3.x
Status: Open
Resolution: None
Priority: 3
Submitted By: Randall Lucas (rlucas)
Assigned to: Nobody (None)
Summary: Gem.binary_mode version test for Ruby 1.9 sets invalid rb:ascii-8bit mode

Initial Comment:
In rubygems.rb, line 344, self.binary_mode makes a check for RUBY_VERSION and sets @binary_mode accordingly.  However, it assumes wrongly that the mode "rb:ascii-8bit" is available for all RUBY_VERSION > '1.9'.  In fact, that mode does NOT work in Ruby 1.9.0, and was added in 1.9.1.  (See support below from Ruby core SVN.)

This manifests as a cryptic error:

ERROR:  While executing gem ... (ArgumentError)
    illegal access mode rb:ascii-8bit

(full debugging error output below).

Suggested fix: alter self.binary_mode to check for RUBY_VERSION > '1.9.0' thus:

binary_mode ||= RUBY_VERSION > '1.9.0' ? 'rb:ascii-8bit' : 'rb'

---
Support from Ruby core SVN for the mode name-change that breaks between 1.9.0 and 1.9.1:

>From http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v1_9_0_5/enc/ascii.c?view=log

Revision 13670  - (view) (download) (annotate) - [select for diffs]
Modified Wed Oct 10 06:50:33 2007 UTC (2 years, 6 months ago) by akr
Original Path: trunk/ascii.c
File length: 2408 byte(s)
Diff to previous 12376 (colored)

* encoding.c (rb_enc_init): don't alias iso-8859-1 to ascii.

* ascii.c (OnigEncodingASCII): change the name US-ASCII to ASCII-8BIT.


---
version info:

$ uname -a
Linux arrakis 2.6.18-6-amd64 #1 SMP Sat Feb 20 23:34:55 UTC 2010 x86_64 GNU/Linux

$ ruby -v
ruby 1.9.0 (2006-06-08) [x86_64-linux]

$ sudo gem --debug install rake
Exception `NameError' at /usr/local/lib/site_ruby/1.9/rubygems/command_manager.rb:163 - uninitialized constant Gem::Commands::InstallCommand
Exception `Gem::LoadError' at /usr/local/lib/site_ruby/1.9/rubygems.rb:778 - Could not find RubyGem test-unit (>= 0)

Exception `Gem::LoadError' at /usr/local/lib/site_ruby/1.9/rubygems.rb:778 - Could not find RubyGem sources (> 0.0.1)

Exception `ArgumentError' at /usr/local/lib/site_ruby/1.9/rubygems/format.rb:50 - illegal access mode rb:ascii-8bit
ERROR:  While executing gem ... (ArgumentError)
    illegal access mode rb:ascii-8bit
        /usr/local/lib/site_ruby/1.9/rubygems/format.rb:50:in `initialize'
        /usr/local/lib/site_ruby/1.9/rubygems/format.rb:50:in `Gem::Format#from_file_by_path'
        /usr/local/lib/site_ruby/1.9/rubygems/installer.rb:118:in `initialize'
        /usr/local/lib/site_ruby/1.9/rubygems/dependency_installer.rb:257:in `Gem::DependencyInstaller#install'
        /usr/local/lib/site_ruby/1.9/rubygems/dependency_installer.rb:240:in `Gem::DependencyInstaller#install'
        /usr/local/lib/site_ruby/1.9/rubygems/commands/install_command.rb:119:in `execute'
        /usr/local/lib/site_ruby/1.9/rubygems/commands/install_command.rb:116:in `execute'
        /usr/local/lib/site_ruby/1.9/rubygems/command.rb:258:in `Gem::Command#invoke'
        /usr/local/lib/site_ruby/1.9/rubygems/command_manager.rb:134:in `process_args'
        /usr/local/lib/site_ruby/1.9/rubygems/command_manager.rb:104:in `Gem::CommandManager#run'
        /usr/local/lib/site_ruby/1.9/rubygems/gem_runner.rb:58:in `Gem::GemRunner#run'
        /usr/bin/gem:21

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.6
  - RUBY VERSION: 1.9.0 (2006-06-08) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/lib/ruby1.9/gems/1.9
  - RUBY EXECUTABLE: /usr/bin/ruby1.9
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/lib/ruby1.9/gems/1.9
     - /home/rlucas/.gem/ruby/1.9
  - 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=28154&group_id=126


More information about the Rubygems-developers mailing list