Forum: Ruby command line rubygems and require

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.
10e3653e8f411fa2d140129b947cdaea?d=identicon&s=25 polypus (Guest)
on 2006-05-10 05:54
given the file requires_foo.rb

require 'foo'

class ReqFoo
end

if foo is a gem, then i can run it by going:

ruby -rubygems requires_foo.rb

why can't i have a file requires_foo2.rb

class ReqFoo
end

and go:

ruby -rubygems -r foo requires_foo2.rb

it's giving me a LoadError

but maybe i'm approaching the problem wrong. what i'm doing is that i
have a large file which is a tutorial to my lib in rdoc, and which is
doing an :include: of my examples when need be, in order for my example
code to be writen in only one place. the problem is that i don't want a
whole lot of requires and shebangs and whatnot in the examples. is there
a standard proceedure for this kind of thing? ideas/suggestions for an
rdoc noob? my solution is just to have a little shell script in the
examples directory which goes something like:

ruby -rubygems -r foo example$1.rb

but then there's the problem listed above.

thanks,
_c
10e3653e8f411fa2d140129b947cdaea?d=identicon&s=25 polypus (Guest)
on 2006-05-10 06:03
>my solution is just to have a little shell script in the
>examples directory which goes something like:

ok i've rewritten my little shell script in ruby solving my main
problem, but am still curious about the command line procedure.
10d4acbfdaccb4eee687a428ca00a5d8?d=identicon&s=25 Jim Weirich (weirich)
on 2006-05-10 06:06
polypus wrote:
> why can't i have a file requires_foo2.rb
>
> class ReqFoo
> end
>
> and go:
>
> ruby -rubygems -r foo requires_foo2.rb

RubyGems wraps the require command in order to locate the gem
directories during a require.  The -r option bypasses the require
command entirely and attempts to load the file without allowing RubyGems
to do its thang.

Sorry.

-- Jim Weirich
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2006-05-10 06:08
(Received via mailing list)
On May 9, 2006, at 11:54 PM, polypus wrote:

>
>
> examples directory which goes something like:
>
You could do

ruby -rubygems -e 'require 'foo'; load(ARGV.shift)' requires_foo2.rb
10e3653e8f411fa2d140129b947cdaea?d=identicon&s=25 polypus (Guest)
on 2006-05-10 15:40
>> examples directory which goes something like:
>>
> You could do
>
> ruby -rubygems -e 'require 'foo'; load(ARGV.shift)' requires_foo2.rb

thanks guys
This topic is locked and can not be replied to.