Forum: Ruby Requiring libraries in command line scripts?

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.
429500a5a54600958c9c7ac032a37f66?d=identicon&s=25 Joe (Guest)
on 2006-06-02 03:28
I have a simple script:

#!/usr/bin/ruby

require 'rubilicious'
#require '/usr/lib/ruby/gems/1.8/gems/Rubilicious-0.1.5/rubilicious.rb'

r = Rubilicious.new('joe', '12345')

r.add('http://yahoo.com', 'yahoo')

When run, I get:
`require': no such file to load -- rubilicious (LoadError)

But if I comment out the first require, and uncomment the second, it
works. Is there something I can do so that command line scripts don't
have to specify the full path when including library files?

Thanks,
Joe
3afd3e5e05dc9310c89aa5762cc8dd1d?d=identicon&s=25 Timothy Hunter (Guest)
on 2006-06-02 03:36
(Received via mailing list)
Joe wrote:
>
>
Don't you need to require 'rubygems' before requiring a gem?
429500a5a54600958c9c7ac032a37f66?d=identicon&s=25 Joe (Guest)
on 2006-06-02 03:49
Timothy Hunter wrote:
> Joe wrote:
>>
>>
> Don't you need to require 'rubygems' before requiring a gem?


Ah, yep, you're right! I thought I had gotten such scripts to work
before.

Thanks,
Joe
8dad1ec4d769734583f45fbbee5cd009?d=identicon&s=25 Jeff Pritchard (Guest)
on 2006-06-02 04:01
This is interesting.

How does this work?  Does the rubygems library replace the "require"
keyword with an implementation that is gem savvy and knows where to look
for them?  Does gems always install things in this one standard "place"?

thanks,
jp


Timothy Hunter wrote:
> Joe wrote:
>>
>>
> Don't you need to require 'rubygems' before requiring a gem?
31af45939fec7e3c4ed8a798c0bd9b1a?d=identicon&s=25 Matthew Smillie (Guest)
on 2006-06-02 05:17
(Received via mailing list)
On Jun 2, 2006, at 3:01, Jeff Pritchard wrote:

> This is interesting.
>
> How does this work?  Does the rubygems library replace the "require"
> keyword with an implementation that is gem savvy and knows where to
> look
> for them?  Does gems always install things in this one standard
> "place"?

You pretty much got it in one.

(though technically, 'require' is a method, not a keyword)

matthew smillie.
This topic is locked and can not be replied to.