Forum: Ruby ruby and library paths

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dale (Guest)
on 2007-01-25 09:36
(Received via mailing list)
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
Pit C. (Guest)
on 2007-01-25 10:10
(Received via mailing list)
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
>         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
Dale (Guest)
on 2007-01-25 10:18
(Received via mailing list)
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>
Dale (Guest)
on 2007-01-25 10:20
(Received via mailing list)
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
Pit C. (Guest)
on 2007-01-25 10:29
(Received via mailing list)
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

   require "rubygems"
   require "fcgi"

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

Regards,
Pit
Dale (Guest)
on 2007-01-25 10:48
(Received via mailing list)
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>
unknown (Guest)
on 2007-01-25 11:05
(Received via mailing list)
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
Dale (Guest)
on 2007-01-25 11:22
(Received via mailing list)
Thanks Phill.

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

Dale
This topic is locked and can not be replied to.