# Strange require behaviour

**URL:** <https://www.ruby-forum.com/t/strange-require-behaviour/235390>\
**Category:** Ruby\
**Created:** [June 19, 2013, 9:30am UTC](https://www.ruby-forum.com/t/strange-require-behaviour/235390 "2013-06-19T09:30:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [June 19, 2013, 9:30am UTC](https://www.ruby-forum.com/t/strange-require-behaviour/235390/1 "2013-06-19T09:30:36Z")

</div>

Why does gem ‘bson\_ext’ work, but require ‘bson\_ext’ does not. Ruby  
1.9.3. Same on Windows or Linux.

C:\irb  
irb(main):001:0\> require ‘bson\_ext’  
LoadError: cannot load such file – bson\_ext  
from  
c:/Ruby193/lib/ruby/site\_ruby/1.9.1/rubygems/custom\_require.rb:36:in  
`require' from c:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in`require’  
from (irb):1  
from c:/Ruby193/bin/irb:12:in `’  
irb(main):002:0\> gem ‘bson\_ext’  
=\> true  
irb(main):003:0\>

by  
TheR

---

<div class="post-metadata">

**Author:** ![ther](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/977dab/32.png) [@ther](https://www.ruby-forum.com/u/ther)\
**Post date:** [June 19, 2013, 9:57am UTC](https://www.ruby-forum.com/t/strange-require-behaviour/235390/2 "2013-06-19T09:57:27Z")

</div>

I found this about the “gem” command within IRB:

## Kernel#gem gem(gem\_name, \*version\_requirements)

```
 Adds a Ruby Gem to the $LOAD_PATH. Before a Gem is loaded, its
 required Gems are loaded. If the version information is omitted,
 the highest version Gem of the supplied name is loaded. If a Gem
 is not found that meets the version requirement and/or a required
 Gem is not found, a Gem::LoadError is raised. More information on
 version requirements can be found in the Gem::Version
 documentation.

 The gem directive should be executed before any require statements
 (otherwise rubygems might select a conflicting library version).

 You can define the environment variable GEM_SKIP as a way to not
 load specified gems. you might do this to test out changes that
 haven't been intsalled yet. Example:

   GEM_SKIP=libA:libB ruby-I../libA -I../libB ./mycode.rb

 gem: [String or Gem::Dependency] The gem name or
                      dependency instance.

 version_requirement: [default=">= 0.0.0"] The version requirement.

 return: [Boolean] true if the Gem is loaded,
                      otherwise false.

 raises: [Gem::LoadError] if Gem cannot be found, is
                      listed in GEM_SKIP, or version requirement
                      not met.

```

–

I’d guess that you haven’t installed the gem correctly, so it isn’t in  
the right location for “require” to work.

---

<div class="post-metadata">

**Author:** ![ther](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/977dab/32.png) [@ther](https://www.ruby-forum.com/u/ther)\
**Post date:** [July 4, 2013, 4:56am UTC](https://www.ruby-forum.com/t/strange-require-behaviour/235390/3 "2013-07-04T04:56:55Z")

</div>

That certainly looks like my problem. Since I have tried reloading Ruby  
Gems through RVM twice (and since RVM is supposed to be the most  
reliable way of installing Ruby) how do I fix this problem?
