Bug 808573

Summary: rubygems passes an unsupported argument to File.read in ruby 1.8.7
Product: Red Hat Enterprise Linux 6 Reporter: Mike <mrkfact>
Component: rubygemsAssignee: Vít Ondruch <vondruch>
Status: CLOSED WORKSFORME QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.2CC: gconradi, lkocman
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-08-13 06:23:50 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mike 2012-03-30 18:28:32 UTC
Description of problem:

The rubygems package seems to conflict with the version of ruby that is provided in RHEL6.

In /usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb, "File.read file_name, :encoding => 'UTF-8'" is used in the load_specification() method, but IO.read() in Ruby 1.8.7 does not support the passing of the :encoding hash.

Here is the code snippet:

    def load_specification(file_name)
      return nil unless file_name and File.exist? file_name

      spec_code = if defined? Encoding then
                    File.read file_name, :encoding => 'UTF-8'
                  else
                    File.read file_name
                  end.untaint


And the reproducer:
[mkrysiak@unixdeva16 tmp]$ touch x.rb
[mkrysiak@unixdeva16 tmp]$ irb
irb(main):001:0> File.read 'x.rb', :encoding => 'UTF-8'
TypeError: can't convert Hash into Integer
        from (irb):1:in `read'
        from (irb):1
        from :0

It looks like this feature was added in Ruby 1.9.
http://ruby-doc.org/core-1.8.7/IO.html#method-c-read
http://ruby-doc.org/core-1.9.3/IO.html#method-c-read

Version-Release number of selected component (if applicable):
ruby-1.8.7.299-7.el6.x86_64
rubygems-1.3.7-1.el6.noarch

Comment 2 Vít Ondruch 2012-07-24 08:51:11 UTC
(In reply to comment #0)

Hi Mike,

Could you please be more specific? Under what circumstances it bites you? The Encoding class is not defined by default in Ruby 1.8.7, so it should use the "else" branch and works just fine IMO.

Comment 3 RHEL Program Management 2012-09-07 05:25:25 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.

Comment 4 Vít Ondruch 2013-08-13 06:23:50 UTC
I am not able to reproduce this issue and no additional info was provided in year. I am closing this ticket as "WORKSFORME". Please feel free to reopen this ticket if you have more information.