ruby and library paths

D

Dale

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 returns true from within irb.

$ irb
irb(main):001:0> require fcgi.so
NameError: undefined local variable or method `fcgi' for main:Object
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
^
(irb):2: parse error, unexpected tINTEGER
require /usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.so
^
from (irb):2
from :0

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
 
P

Pit Capitain

Dale said:
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
from (irb):1

Hi Dale, welcome to Ruby!

You have to put quotes around fcgi, like

require "fcgi"

or

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
 
D

Dale

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
from (irb):1:in `require'
from (irb):1
irb(main):002:0> require "fcgi.so"
LoadError: no such file to load -- fcgi.so
from (irb):2:in `require'
from (irb):2
irb(main):003:0>
 
D

Dale

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
 
P

Pit Capitain

Dale said:
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

require "rubygems"
require "fcgi"

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

Regards,
Pit
 
D

Dale

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>
 
C

cmdjackryan

Dale said:
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
 
D

Dale

Thanks Phill.

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

Dale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top