# Ruby and library paths

**URL:** <https://rubytalk.org/t/ruby-and-library-paths/34786>\
**Category:** ruby-talk\
**Created:** [25 January 2007 07:35 UTC](https://rubytalk.org/t/ruby-and-library-paths/34786 "2007-01-25T07:35:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dale1](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dale1](https://rubytalk.org/u/Dale1)\
**Post date:** [25 January 2007 07:35 UTC](https://rubytalk.org/t/ruby-and-library-paths/34786/1 "2007-01-25T07:35:29Z")

</div>

Hi there

I'm (brand) new to Ruby, so treat my questions in that light. On trying to install Beast (web forum software on Rails) I am required to test that requiring fcgi, or [fcgi.so](http://fcgi.so) returns true from within irb.

$ irb  
irb(main):001:0\> require [fcgi.so](http://fcgi.so)  
NameError: undefined local variable or method `fcgi' for main:Object  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):1

I guessed that there may be an issue with paths, so tried the full path to the lib.

irb(main):002:0\> require /usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.so  
SyntaxError: compile error  
(irb):2: unknown regexp options - lb  
(irb):2: no .\<digit\> floating literal anymore; put 0 before dot  
require /usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.so  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;^  
(irb):2: parse error, unexpected tINTEGER  
require /usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.so  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;^  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):2

The above has worked before (ie. using the full path), giving the output 'true'.

I have two questions.

1) How do I configure things so that I don't have to specify the full path to a lib.  
2) How do I resolve the above error? Should I be speaking to the ruby-fcgi guys?

OS slackware linux  
ruby 1.8.5-p2  
ruby fcgi 0.8.7  
fcgi 2.4.0

Thanks  
Dale

> **···**
>
> from :0

---

<div class="post-metadata">

**Author:** ![Pit](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@Pit](https://rubytalk.org/u/Pit)\
**Post date:** [25 January 2007 08:09 UTC](https://rubytalk.org/t/ruby-and-library-paths/34786/2 "2007-01-25T08:09:48Z")

</div>

Dale schrieb:

> I'm (brand) new to Ruby, so treat my questions in that light. On trying to install Beast (web forum software on Rails) I am required to test that requiring fcgi, or fcgi.so returns true from within irb.
> 
> $ irb  
> irb(main):001:0\> require fcgi.so  
> NameError: undefined local variable or method `fcgi' for main:Object  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):1

Hi Dale, welcome to Ruby!

You have to put quotes around fcgi, like

&nbsp;&nbsp;&nbsp;require "fcgi"

or

&nbsp;&nbsp;&nbsp;require "fcgi.so"

Otherwise Ruby tries to find a local variable or a method called fcgi, and then you get the NameError you've shown.

Regards,  
Pit

---

<div class="post-metadata">

**Author:** ![Dale1](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dale1](https://rubytalk.org/u/Dale1)\
**Post date:** [25 January 2007 08:17 UTC](https://rubytalk.org/t/ruby-and-library-paths/34786/3 "2007-01-25T08:17:51Z")

</div>

Thanks for the advice Pit, but there still appears to be a path issue? Any other suggestions? Thanks.

$ irb  
irb(main):001:0\> require "fcgi"  
LoadError: no such file to load -- fcgi  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):1:in `require'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):1  
irb(main):002:0\> require "fcgi.so"  
LoadError: no such file to load -- fcgi.so  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):2:in `require'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):2  
irb(main):003:0\>

Pit Capitain wrote:

> **···**
>
> > You have to put quotes around fcgi, like
> > 
> > &nbsp;&nbsp;require "fcgi"
> > 
> > or
> > 
> > &nbsp;&nbsp;require "fcgi.so"
> > 
> > Otherwise Ruby tries to find a local variable or a method called fcgi, and then you get the NameError you've shown.

---

<div class="post-metadata">

**Author:** ![Dale1](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dale1](https://rubytalk.org/u/Dale1)\
**Post date:** [25 January 2007 08:19 UTC](https://rubytalk.org/t/ruby-and-library-paths/34786/4 "2007-01-25T08:19:53Z")

</div>

This does work though... absolute path to lib, so there must be a path issue in terms of irb's environment?

irb(main):003:0\> require "/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.so"  
=\> true

Dale wrote:

> **···**
>
> > Thanks for the advice Pit, but there still appears to be a path issue? Any other suggestions? Thanks.
> > 
> > $ irb  
> > irb(main):001:0\> require "fcgi"  
> > LoadError: no such file to load -- fcgi  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):1:in `require'  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):1  
> > irb(main):002:0\> require "fcgi.so"  
> > LoadError: no such file to load -- fcgi.so  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):2:in `require'  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):2  
> > irb(main):003:0\>

---

<div class="post-metadata">

**Author:** ![Pit](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@Pit](https://rubytalk.org/u/Pit)\
**Post date:** [25 January 2007 08:29 UTC](https://rubytalk.org/t/ruby-and-library-paths/34786/5 "2007-01-25T08:29:13Z")

</div>

Dale schrieb:

> This does work though... absolute path to lib, so there must be a path issue in terms of irb's environment?
> 
> irb(main):003:0\> require "/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.so"  
> =\> true

Hi Dale, I have no Linux, so I can't tell you much more. But to be able to use gems, you first have to load the ruygems library itself. So try

&nbsp;&nbsp;&nbsp;require "rubygems"  
&nbsp;&nbsp;&nbsp;require "fcgi"

If this doesn't work, someone else has to help you further.

Regards,  
Pit

---

<div class="post-metadata">

**Author:** ![Dale1](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dale1](https://rubytalk.org/u/Dale1)\
**Post date:** [25 January 2007 08:47 UTC](https://rubytalk.org/t/ruby-and-library-paths/34786/6 "2007-01-25T08:47:29Z")

</div>

Ha! Super! You were spot on. Thanks!

$ irb  
irb(main):001:0\> require "rubygems"  
=\> true  
irb(main):002:0\> require "fcgi"  
=\> true  
irb(main):003:0\>

Pit Capitain wrote:

> **···**
>
> > Hi Dale, I have no Linux, so I can't tell you much more. But to be able to use gems, you first have to load the ruygems library itself. So try
> > 
> > &nbsp;&nbsp;require "rubygems"  
> > &nbsp;&nbsp;require "fcgi"

---

<div class="post-metadata">

**Author:** ![Phil](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@Phil](https://rubytalk.org/u/Phil)\
**Post date:** [25 January 2007 09:04 UTC](https://rubytalk.org/t/ruby-and-library-paths/34786/7 "2007-01-25T09:04:08Z")

</div>

Dale schrieb:

> Ha! Super! You were spot on. Thanks!
> 
> $ irb  
> irb(main):001:0\> require "rubygems"  
> =\> true  
> irb(main):002:0\> require "fcgi"  
> =\> true  
> irb(main):003:0\>

If you are going to work with rubygems more often, it is a good idea to add RUBYOPT=-rubygems to your .bash\_rc. This allows you to just use require "library|code\_snippet" in the future.

HTH,  
Phill

---

<div class="post-metadata">

**Author:** ![Dale1](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@Dale1](https://rubytalk.org/u/Dale1)\
**Post date:** [25 January 2007 09:20 UTC](https://rubytalk.org/t/ruby-and-library-paths/34786/8 "2007-01-25T09:20:57Z")

</div>

Thanks Phill.

I'm impressed by the immediate and useful help from folks on this ML so far! Much appreciated!

Dale

cmdjackryan@googlemail.com wrote:

> **···**
>
> > If you are going to work with rubygems more often, it is a good idea to add RUBYOPT=-rubygems to your .bash\_rc. This allows you to just use require "library|code\_snippet" in the future.
