Project

General

Profile

Bug #3561

ruby-1.9.3-r28570 test/unit gem activation failure

Added by rubys (Sam Ruby) about 9 years ago. Updated about 8 years ago.

Status:
Open
Priority:
Normal
Assignee:
-
ruby -v:
ruby 1.9.3dev (2010-07-07 trunk 28570) [x86_64-linux]
[ruby-core:31212]

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

History

#1

Updated by tenderlovemaking (Aaron Patterson) about 9 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

#2

Updated by drbrain (Eric Hodel) about 9 years ago

=begin
Yes, whenever you use a gem that replaces stdlib functionality you should use #gem before #require.
=end

Also available in: Atom PDF