[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Question about -r command line option, rubygems

Daniel Berger

11/18/2006 1:12:00 AM

Hi all,

Ruby 1.8.5 (one click)
Windows XP

I'm trying to require a gem from the command line but it's failing:

>C:\ruby -rubygems -rturn test.rb
ruby: no such file to load -- turn (LoadError)

But, I clearly have it installed:

>C:\>ruby -e "require 'turn'"
Loaded suite .
==============================================================================
pass: 0, fail: 0, error: 0
total: 0 tests with 0 assertions in 0.0 seconds
==============================================================================

What am I doing wrong?

Regards,

Dan

3 Answers

David Vallner

11/18/2006 1:22:00 AM

0

Daniel Berger wrote:
> Hi all,
>
> Ruby 1.8.5 (one click)
> Windows XP
>
> I'm trying to require a gem from the command line but it's failing:
>
>>C:\ruby -rubygems -rturn test.rb
> ruby: no such file to load -- turn (LoadError)
>
> But, I clearly have it installed:
>
>>C:\>ruby -e "require 'turn'"
> Loaded suite .
> ==============================================================================
>
> pass: 0, fail: 0, error: 0
> total: 0 tests with 0 assertions in 0.0 seconds
> ==============================================================================
>

-r probably only uses the "vanilla" semantics of require, and only
interpreted code picks up the hacks^Wimprovements that rubygems makes.

David Vallner

Chad Fowler

11/18/2006 3:59:00 PM

0

On 11/17/06, Daniel Berger <djberg96@gmail.com> wrote:
> Hi all,
>
> Ruby 1.8.5 (one click)
> Windows XP
>
> I'm trying to require a gem from the command line but it's failing:
>
> >C:\ruby -rubygems -rturn test.rb
> ruby: no such file to load -- turn (LoadError)
>
> But, I clearly have it installed:
>
> >C:\>ruby -e "require 'turn'"
> Loaded suite .
> ==============================================================================
> pass: 0, fail: 0, error: 0
> total: 0 tests with 0 assertions in 0.0 seconds
> ==============================================================================
>
> What am I doing wrong?

The problem is that unfortunately the -r option doesn't use the
hookable require method, but rather the C function that require
delegates to (which isn't a Ruby method, so it's not overrideable).
So, you're not doing anything wrong.

Chad

Daniel Berger

11/20/2006 2:30:00 PM

0

Chad Fowler wrote:

<snip>

> > What am I doing wrong?
>
> The problem is that unfortunately the -r option doesn't use the
> hookable require method, but rather the C function that require
> delegates to (which isn't a Ruby method, so it's not overrideable).
> So, you're not doing anything wrong.

Hm, could it be altered to use the hookable require method? If so, what
would be the downside?

- Dan