List Info

Thread: request_gem vs. gem




request_gem vs. gem
country flaguser name
United States
2007-03-08 13:48:02
Sorry if this is an FAQ. Web searching wasn't fruitful.

Consider the following:

$ irb1.8
irb(main):001:0> require "rubygems"
=> true
irb(main):002:0> require_gem "fcgi"
(irb):2:Warning: require_gem is obsolete.  Use gem instead.
=> true
irb(main):003:0> FCGI
=> FCGI

That seems to work fine, except for the warning about
require_gem
being obsolete.

So consider instead:

$ irb1.8
irb(main):001:0> require "rubygems"
=> true
irb(main):002:0> gem "fcgi"
=> true
irb(main):003:0> FCGI
NameError: uninitialized constant FCGI
        from (irb):3

That doesn't seem to work at all.

Am I missing something obvious?

                                        Be seeing you,
                                          norm

-- 
Norman Walsh <ndwnwalsh.com> | Men are more like the
times they live
http://nwalsh.com/         
  | in than they are like their
                              | fathers.--Ali Ibn-abi-talib

_______________________________________________
Rubygems-developers mailing list
Rubygems-developersrubyforge.org
http://rubyforge.org/mailman/listinfo/rubygems-develope
rs
Re: request_gem vs. gem
user name
2007-03-08 15:55:54
On 3/8/07, Norman Walsh <ndwnwalsh.com> wrote:
> Sorry if this is an FAQ. Web searching wasn't
fruitful.
> Am I missing something obvious?

Yes. gem doesn't autorequire. Autorequire was thought to be
a good
idea, but it turned out to be a mediocre-at-best idea in
practice. It
is therefore deprecated.

So:

1. Don't use #require_gem -- that does autorequire and it
will be
removed for RubyGems 1.0.
2. Only use #gem when you're trying to fix the gem version
to a
specific version. The only time when you want to use #gem
without a
version specification is for gems like soap4r, where partial
files are
in the standard library but you need to use a wholly
different version
than is in the standard library.
3. Just use "require 'fcgi'" or whatever the
appropriate require for
the files contained in the gem are.

-austin
-- 
Austin Ziegler * halostatuegmail.com * http://www.halostatue.ca/
               * austinhalostatue.ca * http://www.halostatue.
ca/feed/
               * austinzieglers.ca
_______________________________________________
Rubygems-developers mailing list
Rubygems-developersrubyforge.org
http://rubyforge.org/mailman/listinfo/rubygems-develope
rs

Re: request_gem vs. gem
country flaguser name
Germany
2007-03-08 15:42:56
On 2007-03-08 14:48:02 -0500, Norman Walsh wrote:
> $ irb1.8
> irb(main):001:0> require "rubygems"
> => true
> irb(main):002:0> gem "fcgi"
> => true
> irb(main):003:0> FCGI
> NameError: uninitialized constant FCGI
>         from (irb):3
> 
> That doesn't seem to work at all.
> 
> Am I missing something obvious?

yes. gem 'fcgi' just tells it what library to use.

you need to do require 'fcgi' as last step.

    darix

-- 
           openSUSE - SUSE Linux is my linux
               openSUSE is good for you
                   www.opensuse.org
_______________________________________________
Rubygems-developers mailing list
Rubygems-developersrubyforge.org
http://rubyforge.org/mailman/listinfo/rubygems-develope
rs

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )