# Require 'rubygems' fails (works in irb)

**URL:** <https://www.ruby-forum.com/t/require-rubygems-fails-works-in-irb/182310>\
**Category:** Ruby\
**Created:** [January 26, 2010, 1:10pm UTC](https://www.ruby-forum.com/t/require-rubygems-fails-works-in-irb/182310 "2010-01-26T13:10:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hirodusk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/6f9a4e/32.png) [@hirodusk](https://www.ruby-forum.com/u/hirodusk)\
**Post date:** [January 26, 2010, 1:10pm UTC](https://www.ruby-forum.com/t/require-rubygems-fails-works-in-irb/182310/1 "2010-01-26T13:10:16Z")

</div>

I am getting errors that rubygems cannot be found, when starting  
rails-related ruby commands.

when I run

ls -l `which ruby`

and

cat `which gem` | head -n 1

I get the same directory which is also list in ‘gem env’.

somehow ruby does not know where rubygems is.  
but if I run it under irb:

irb(main):001:0\> require ‘rubygems’  
=\> true

I’m not sure where the missing link is.  
I am running on osx here.

Any help much appreciated.  
Thanks

---

<div class="post-metadata">

**Author:** ![hirodusk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/6f9a4e/32.png) [@hirodusk](https://www.ruby-forum.com/u/hirodusk)\
**Post date:** [January 26, 2010, 3:27pm UTC](https://www.ruby-forum.com/t/require-rubygems-fails-works-in-irb/182310/2 "2010-01-26T15:27:31Z")

</div>

Adam W. wrote:

> I am getting errors that rubygems cannot be found, when starting  
> rails-related ruby commands.

Please ask on a Rails mailing list if you are having problems with  
Rails. Rails frigs about with the ‘require’ and rubygems mechanisms in  
its own strange ways, and they’re nothing to do with Ruby.

> somehow ruby does not know where rubygems is.

The Rails mailing list would probably like to see your _exact_ error  
message.
