This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.

Requiring a Specific Version of a Gem
CodeExpectedActual
require 'rubygems'
require 'cmdparse'
true true
require_gem 'nosuchgem'
Gem::LoadError: Could not find RubyGem nosuchgem (> 0.0.0)
...
Gem::LoadError: Could not find RubyGem nosuchgem (> 0.0.0)

	from /usr/local/lib/site_ruby/1.8/rubygems.rb:204:in `report_activate_error'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:141:in `activate'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:37:in `require_gem_with_options'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:31:in `require_gem'
	from (irb):3
require_gem 'cmdparse', '>= 1.0'
false false
require_gem 'cmdparse', '>= 2.0.3'
Gem::LoadError: RubyGem version error: cmdparse(2.0.0 not >= 2.0.3)
...
Gem::LoadError: RubyGem version error: cmdparse(2.0.0 not >= 2.0.3)

	from /usr/local/lib/site_ruby/1.8/rubygems.rb:204:in `report_activate_error'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:141:in `activate'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:37:in `require_gem_with_options'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:31:in `require_gem'
	from (irb):5
require_gem 'gem_1' '= 1.0.1'
require_gem 'gem_2' '= 2.6'
require_gem 'gem_3' '= 1.3.2'
require_gem 'buggy' '!=1.0.3'
require_gem 'my_gem' '>= 2.0'
require_gem 'my_gem' '< 3'
...
Gem::LoadError: Could not find RubyGem gem_1= 1.0.1 (> 0.0.0)

	from /usr/local/lib/site_ruby/1.8/rubygems.rb:204:in `report_activate_error'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:141:in `activate'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:37:in `require_gem_with_options'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:31:in `require_gem'
	from (irb):6
Gem::LoadError: Could not find RubyGem gem_2= 2.6 (> 0.0.0)

	from /usr/local/lib/site_ruby/1.8/rubygems.rb:204:in `report_activate_error'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:141:in `activate'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:37:in `require_gem_with_options'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:31:in `require_gem'
	from (irb):7
Gem::LoadError: Could not find RubyGem gem_3= 1.3.2 (> 0.0.0)

	from /usr/local/lib/site_ruby/1.8/rubygems.rb:204:in `report_activate_error'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:141:in `activate'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:37:in `require_gem_with_options'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:31:in `require_gem'
	from (irb):8
Gem::LoadError: Could not find RubyGem buggy!=1.0.3 (> 0.0.0)

	from /usr/local/lib/site_ruby/1.8/rubygems.rb:204:in `report_activate_error'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:141:in `activate'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:37:in `require_gem_with_options'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:31:in `require_gem'
	from (irb):9
Gem::LoadError: Could not find RubyGem my_gem>= 2.0 (> 0.0.0)

	from /usr/local/lib/site_ruby/1.8/rubygems.rb:204:in `report_activate_error'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:141:in `activate'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:37:in `require_gem_with_options'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:31:in `require_gem'
	from (irb):10
Gem::LoadError: Could not find RubyGem my_gem< 3 (> 0.0.0)

	from /usr/local/lib/site_ruby/1.8/rubygems.rb:204:in `report_activate_error'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:141:in `activate'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:37:in `require_gem_with_options'
	from /usr/local/lib/site_ruby/1.8/rubygems.rb:31:in `require_gem'
	from (irb):11