rubinius/rubinius — Issue #1525: Trouble with Rubygems vs stdlib
Author: djberg96
Created: 2012-01-19 18:00:26+00:00
State: open

It seems that Rubinius is not setting $: properly when explicitly trying to use a rubygem vs a library from the standard library with the same name.

Specificaly, I'm trying to use test-unit 2 instead of the test-unit library that ships as part of the standard library. Here's some sample code and a description of my environment, plus some $: info.

require 'rubygems'
gem 'test-unit'
require 'test/unit'

class TC_Foo < Test::Unit::TestCase
test "test-unit 2 works as expected" do
assert_true(1 == 1)
end
end

I definitely have the gem installed

>rbx -S gem list

*** LOCAL GEMS ***

rubygems-update (1.8.15)
test-unit (2.4.5)

Here's my environment

>rbx -S gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.15
- RUBY VERSION: 1.8.7 (yyyy-mm-dd patchlevel 0) [x86_64-apple-darwin10.8.0]
- INSTALLATION DIRECTORY: /opt/test/rubinius/2.0/gems/1.8
- RUBYGEMS PREFIX: /opt/test/rubinius/2.0
- RUBY EXECUTABLE: /opt/test/rubinius/2.0/bin/rbx
- EXECUTABLE DIRECTORY: /opt/test/rubinius/2.0/gems/1.8/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- x86_64-rubinius-2.0
- GEM PATHS:
- /opt/test/rubinius/2.0/gems/1.8
- /Users/djberge/.gem/rbx/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/

Here's the error that indicates it's trying to use test-unit in the stdlib

>rbx test.rb
An exception occurred running test.rb
method 'test': given 1, expected 3 (ArgumentError)

Backtrace:
TC_Foo.__class_init__ (TC_Foo) at test.rb:6
Object#__script__ at test.rb:5
Rubinius::CodeLoader#load_script at kernel/delta/codeloader.rb:67
Rubinius::CodeLoader.load_script at kernel/delta/codeloader.rb:109
Rubinius::Loader#script at kernel/loader.rb:630
Rubinius::Loader#main at kernel/loader.rb:834
Loaded suite test
Started
F
Finished in 0.00357 seconds.

1) Failure:
default_test(TC_Foo)
[kernel/bootstrap/array.rb:68:in `each'
kernel/bootstrap/array.rb:68:in `each']:
No tests were specified.

1 tests, 1 assertions, 1 failures, 0 errors

The output of $: after the "gem 'test-unit'" on line 5:

["/opt/test/rubinius/2.0/lib/18", "/opt/test/rubinius/2.0/gems/1.8/gems/test-unit-2.4.5/lib", "/opt/test/rubinius/2.0/site", "/opt/test/rubinius/2.0/site/x86_64-darwin10.8.0", "/opt/test/rubinius/2.0/vendor", "/opt/test/rubinius/2.0/vendor/x86_64-darwin10.8.0", "/opt/test/rubinius/2.0/lib", "."]

Here's the output of $: when using MRI:

["/usr/local/lib/ruby/gems/1.8/gems/test-unit-2.4.5/lib", "/usr/local/lib/ruby/site_ruby/1.8", "/usr/local/lib/ruby/site_ruby/1.8/i686-darwin10.8.0", "/usr/local/lib/ruby/site_ruby", "/usr/local/lib/ruby/vendor_ruby/1.8", "/usr/local/lib/ruby/vendor_ruby/1.8/i686-darwin10.8.0", "/usr/local/lib/ruby/vendor_ruby", "/usr/local/lib/ruby/1.8", "/usr/local/lib/ruby/1.8/i686-darwin10.8.0", "."]