Bug #3561
closedruby-1.9.3-r28570 test/unit gem activation failure
Description
=begin
Testcase:
require 'rubygems'
require 'test/unit'
require 'test/unit/ui/console/testrunner'
This worked prior to http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28570
Starting with r28570, it produces:
/home/rubys/.rvm/gems/ruby-1.9.3-r28570/gems/test-unit-2.0.9/lib/test/unit/ui/console/testrunner.rb:331:in <module:Console>': uninitialized constant Test::Unit::UI::Console::Diff (NameError) from /home/rubys/.rvm/gems/ruby-1.9.3-r28570/gems/test-unit-2.0.9/lib/test/unit/ui/console/testrunner.rb:17:in
module:UI'
from /home/rubys/.rvm/gems/ruby-1.9.3-r28570/gems/test-unit-2.0.9/lib/test/unit/ui/console/testrunner.rb:16:in <module:Unit>' from /home/rubys/.rvm/gems/ruby-1.9.3-r28570/gems/test-unit-2.0.9/lib/test/unit/ui/console/testrunner.rb:15:in
module:Test'
from /home/rubys/.rvm/gems/ruby-1.9.3-r28570/gems/test-unit-2.0.9/lib/test/unit/ui/console/testrunner.rb:14:in <top (required)>' from /home/rubys/.rvm/rubies/ruby-1.9.3-r28570/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in
require'
from /home/rubys/.rvm/rubies/ruby-1.9.3-r28570/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in rescue in require' from /home/rubys/.rvm/rubies/ruby-1.9.3-r28570/lib/ruby/1.9.1/rubygems/custom_require.rb:31:in
require'
from test0.rb:3:in `'
=end
Updated by tenderlovemaking (Aaron Patterson) over 14 years ago
=begin
I don't believe this is a bug.
The problem is that gem prelude prefers files installed as gems over files from stdlib. That behavior is opposite of rubygems.
The code you've listed works in 1.8.* because test/unit and the testrunner ship with 1.8.
The code you've listed works in 1.9.1 because gem prelude behaves opposite to rubygems. In 1.9, you must install the 'test-unit' gem, and since gem prelude prefers gem files over stdlib files, your require succeeds.
Evan has restored rubygems to work "how it's supposed to work", so I believe this isn't a bug. Instead, you should write your code like so:
require 'rubygems'
gem 'test-unit'
require 'test/unit'
require 'test/unit/ui/console/testrunner'
=end
Updated by drbrain (Eric Hodel) over 14 years ago
=begin
Yes, whenever you use a gem that replaces stdlib functionality you should use #gem before #require.
=end
Updated by jeremyevans0 (Jeremy Evans) about 5 years ago
- Description updated (diff)
- Status changed from Open to Closed