# Gems LoadError in Linux

**URL:** <https://www.ruby-forum.com/t/gems-loaderror-in-linux/180618>\
**Category:** Ruby\
**Created:** [December 23, 2009, 5:19pm UTC](https://www.ruby-forum.com/t/gems-loaderror-in-linux/180618 "2009-12-23T17:19:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rorsch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rorsch](https://www.ruby-forum.com/u/rorsch)\
**Post date:** [December 23, 2009, 5:19pm UTC](https://www.ruby-forum.com/t/gems-loaderror-in-linux/180618/1 "2009-12-23T17:19:37Z")

</div>

Hello,

I’m new to Ruby and I wanna run a test a simple Gem in the latest  
Ubuntu. I’ve downloaded Ruby 1.9.1 and RubyGems, and the Gem I wanna  
test is NFC - which appears installed as a Local Gem after I did $ sudo  
gem install nfc…

The problem happens when I try to run my test code:

require ‘nfc’

loop do  
NFC.instance.find do |tag|  
p tag  
end  
end

Which errors with:  
`require’: no such file to load – nfc (LoadError)

After reading about Gems for a while, I found out that I also need to  
add  
require ‘rubygems’ to the beginning of the code, but that also gives me  
an error:

`require’: no such file to load – rubygems (LoadError)

What am I doing wrong? 😕 Any help will be great.

---

<div class="post-metadata">

**Author:** ![rorsch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rorsch](https://www.ruby-forum.com/u/rorsch)\
**Post date:** [December 23, 2009, 7:33pm UTC](https://www.ruby-forum.com/t/gems-loaderror-in-linux/180618/2 "2009-12-23T19:33:49Z")

</div>

> `require’: no such file to load – rubygems (LoadError)
> 
> What am I doing wrong? 😕 Any help will be great.

Did you install rubygems into the same ruby that you are using to run  
that file?

you could do a  
$ gem which nfc

to see if the file is there, too.

You could also try installing the rubygem _without_ sudo so that it is  
installed to a different location that gems might like more [?]  
-r

---

<div class="post-metadata">

**Author:** ![rorsch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rorsch](https://www.ruby-forum.com/u/rorsch)\
**Post date:** [December 24, 2009, 3:55am UTC](https://www.ruby-forum.com/t/gems-loaderror-in-linux/180618/3 "2009-12-24T03:55:58Z")

</div>

Roger P. wrote:

> Did you install rubygems into the same ruby that you are using to run  
> that file?

How do I know that? I did:

1. $ sudo apt-get install ruby1.9.1-full
2. $ sudo apt-get install rubygems1.9.1

> you could do a  
> $ gem which nfc
> 
> to see if the file is there, too.

that instruction resulted in:

(checking gem nfc-2.0.1 for nfc)  
/var/lib/gems/1.9.1/gems/nfc-2.0.1/lib/nfc.rb

---

<div class="post-metadata">

**Author:** ![rorsch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rorsch](https://www.ruby-forum.com/u/rorsch)\
**Post date:** [December 25, 2009, 4:39pm UTC](https://www.ruby-forum.com/t/gems-loaderror-in-linux/180618/4 "2009-12-25T16:39:37Z")

</div>

On Thu, Dec 24, 2009 at 01:20:07AM +0900, Augusto E. wrote:

> Hello,
> 
> I’m new to Ruby and I wanna run a test a simple Gem in the latest  
> Ubuntu. I’ve downloaded Ruby 1.9.1 and RubyGems, and the Gem I wanna  
> test is NFC - which appears installed as a Local Gem after I did $ sudo  
> gem install nfc…

What OS are you running on? Also, can you provide the output of:

ruby -v  
gem -v

Also the output of ‘gem list nfc’ might be helpful.

> Which errors with:  
> `require’: no such file to load – nfc (LoadError)
> 
> After reading about Gems for a while, I found out that I also need to  
> add  
> require ‘rubygems’ to the beginning of the code, but that also gives me  
> an error:
> 
> `require’: no such file to load – rubygems (LoadError)
> 
> What am I doing wrong? 😕 Any help will be great.

Not sure. This is strange. You _should_ be requiring rubygems at the  
top of your program. But you _shouldn’t_ be getting that error. 🙂

Hopefully the info you provide us with the output of the above commands  
will help us track this down!

---

<div class="post-metadata">

**Author:** ![rorsch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rorsch](https://www.ruby-forum.com/u/rorsch)\
**Post date:** [December 24, 2009, 1:29pm UTC](https://www.ruby-forum.com/t/gems-loaderror-in-linux/180618/5 "2009-12-24T13:29:03Z")

</div>

Got it working. I was using Ubuntu and I had version 1.8 installed  
already. I was installing the gems in ruby1.8 and using ruby1.9

---

<div class="post-metadata">

**Author:** ![rorsch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rorsch](https://www.ruby-forum.com/u/rorsch)\
**Post date:** [August 20, 2010, 5:15pm UTC](https://www.ruby-forum.com/t/gems-loaderror-in-linux/180618/6 "2010-08-20T17:15:32Z")

</div>

Hi, i know that the post is old, but i’m having the same problem, i am  
running Ubuntu 10.04 and installed

ruby1.9.1-full  
rubygems1.9.1

when requiring active record for example:

require ‘rubygems’  
require ‘active\_record’

and run the file i get error:  
`require’: no such file to load – active\_record (LoadError)

I dont have any other versions of ruby, just 1.9.1, any ideas?

Thanks in advanced

Jaime

> On Wednesday, December 23, 2009 11:20 AM Augusto E. wrote:

> add  
> require ‘rubygems’ to the beginning of the code, but that also gives me  
> an error:
> 
> `require’: no such file to load – rubygems (LoadError)
> 
> ## What am I doing wrong? 😕 Any help will be great.
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

> > On Wednesday, December 23, 2009 12:03 PM Aaron P. wrote:

> > Hopefully the info you provide us with the output of the above commands  
> > will help us track this down!
> > 
> > –  
> > Aaron P.  
> > [http://tenderlovemaking.com/](http://tenderlovemaking.com/)

> > > On Wednesday, December 23, 2009 1:35 PM Roger P. wrote:

> > > ## -r
> > > 
> > > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

> > > > On Wednesday, December 23, 2009 9:56 PM Augusto E. wrote:

> > > > (checking gem nfc-2.0.1 for nfc)  
> > > > /var/lib/gems/1.9.1/gems/nfc-2.0.1/lib/nfc.rb
> > > > 
> > > > –  
> > > > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

> > > > > On Thursday, December 24, 2009 7:29 AM Augusto E. wrote:

> > > > > ## Got it working. I was using Ubuntu and I had version 1.8 installed already. I was installing the gems in ruby1.8 and using ruby1.9
> > > > > 
> > > > > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![rorsch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rorsch](https://www.ruby-forum.com/u/rorsch)\
**Post date:** [August 20, 2010, 5:34pm UTC](https://www.ruby-forum.com/t/gems-loaderror-in-linux/180618/7 "2010-08-20T17:34:51Z")

</div>

perhaps, if you try with export GEM\_HOME=“path\_gems” ?

2010/8/20 Jaime G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![rorsch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rorsch](https://www.ruby-forum.com/u/rorsch)\
**Post date:** [August 20, 2010, 5:27pm UTC](https://www.ruby-forum.com/t/gems-loaderror-in-linux/180618/8 "2010-08-20T17:27:49Z")

</div>

Jaime G. wrote:

> Hi, i know that the post is old, but i’m having the same problem, i am  
> running Ubuntu 10.04 and installed
> 
> ruby1.9.1-full  
> rubygems1.9.1
> 
> when requiring active record for example:
> 
> require ‘rubygems’  
> require ‘active\_record’

Recommend trying 1.9.2 or trying it in irb like  
$ ruby --disable-gems -S irb

> > require ‘rubygems’  
> > require ‘active\_record’

---

<div class="post-metadata">

**Author:** ![rorsch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@rorsch](https://www.ruby-forum.com/u/rorsch)\
**Post date:** [September 7, 2010, 2:58pm UTC](https://www.ruby-forum.com/t/gems-loaderror-in-linux/180618/9 "2010-09-07T14:58:47Z")

</div>

Roger P. wrote:

> Jaime G. wrote:
> 
> > Hi, i know that the post is old, but i’m having the same problem, i am  
> > running Ubuntu 10.04 and installed
> > 
> > ruby1.9.1-full  
> > rubygems1.9.1
> > 
> > when requiring active record for example:
> > 
> > require ‘rubygems’  
> > require ‘active\_record’
> 
> Recommend trying 1.9.2 or trying it in irb like  
> $ ruby --disable-gems -S irb
> 
> > > require ‘rubygems’  
> > > require ‘active\_record’

Here’s what happens on my Ubuntu 10.04 box. I may be standing on my air  
hose  
by attempting to have both 1.8.? installed alongside 1.9.1. I would  
like to  
whack both and go to 1.9.2 but I’m afraid of making things worse instead  
of  
better.

[~/sinatra\_etudes]$ ruby1.9.1 sinatra1.rb  
sinatra1.rb:2:in `require': no such file to load -- sinatra (LoadError) from sinatra1.rb:2:in`’  
[~/sinatra\_etudes]$ gem1.9.1 which sinatra  
/usr/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra.rb  
[~/sinatra\_etudes]$ uname -a  
Linux lucid1 2.6.32-24-generic #42-Ubuntu SMP Fri Aug 20 14:24:04 UTC  
2010 i686 GNU/Linux  
[~/sinatra\_etudes]$ ruby1.9.1 -v  
ruby 1.9.1p378 (2010-01-10 revision 26273) [i486-linux]  
[~/sinatra\_etudes]$ gem1.9.1 -v  
1.3.7  
[~/sinatra\_etudes]$ ruby1.9.1 --disable-gems -S irb  
irb(main):001:0\> require ‘rubygems’  
=\> true  
irb(main):002:0\> require ‘sinatra’  
=\> true  
irb(main):004:0\> exit  
[~/sinatra\_etudes]$ export GEM\_HOME=“path\_gems”  
[~/sinatra\_etudes]$ ruby1.9.1 sinatra1.rb  
sinatra1.rb:2:in `require': no such file to load -- sinatra (LoadError) from sinatra1.rb:2:in`’  
[~/sinatra\_etudes]$ export GEM\_HOME="/usr/lib/ruby/gems/1.9.1/gems"  
[~/sinatra\_etudes]$ ruby1.9.1 sinatra1.rb  
sinatra1.rb:2:in `require': no such file to load -- sinatra (LoadError) from sinatra1.rb:2:in`’

So it works in irb but not from the command line.
