RubyGems Issue

Hi list,

I'm having a not-so-critical-but-still-irritating issue with
rubygems. It installed fine, and i can use gems, but only using
require_gem; using the redefined require (from custom_require.rb)
results in a load error. Now, NB, I am running on Ubuntu
(i.e. Debian-based distro), and I know there have been issues w/
rubygems on these platforms before. However, since everything else
seems to work, i was wondering if anybody had insight into this
problem.

e.g. (with any gem, not just fxruby, and I have rubygems in RUBYOPT):

irb(main):001:0> require_gem 'fxruby'
=> true
irb(main):002:0> exit

But:
irb(main):001:0> require 'fxruby'
LoadError: No such file to load -- fxruby
        from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require__'
        from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require'
        from (irb):1
irb(main):002:0> exit

-Patrick

Patrick Fernie wrote:

Hi list,

I'm having a not-so-critical-but-still-irritating issue with
rubygems. It installed fine, and i can use gems, but only using
require_gem; using the redefined require (from custom_require.rb)
results in a load error. Now, NB, I am running on Ubuntu
(i.e. Debian-based distro), and I know there have been issues w/
rubygems on these platforms before. However, since everything else
seems to work, i was wondering if anybody had insight into this
problem.

e.g. (with any gem, not just fxruby, and I have rubygems in RUBYOPT):

irb(main):001:0> require_gem 'fxruby'
=> true
irb(main):002:0> exit

But:
irb(main):001:0> require 'fxruby'
LoadError: No such file to load -- fxruby
        from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__'
        from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:18:in `require'
        from (irb):1
irb(main):002:0> exit

-Patrick

I see the same thing you do. However,

require 'fox12'

works for me, and I have fox installed only as a gem:

$ locate fox12.so
/usr/local/lib/ruby/gems/1.8/gems/fxruby-1.2.6/ext/fox12/fox12.so

(Note that "require 'fox12'" is also the right invocation for systems in which fox was installed from tarball.)

The difference is that require_gem refers to the gem name and the patched require does not, it still refers to the library name. Another example is my gem ParseTree. You can do:

require 'rubygems'
require_gem 'ParseTree' # auto-requires parse_tree
require 'sexp_processor'

Since require_gem can only (currently) auto-require a single library, if you want sexp_processor, you have to do that with a regular require. Alternatively, you can leave the gem names out of it:

require 'rubygems' require nil # require for non-gem setups
require 'parse_tree'
require 'sexp_processor'

Either one works fine. I prefer the latter and am switching all my code to it.

···

On Jun 25, 2005, at 3:02 PM, Patrick Fernie wrote:

I'm having a not-so-critical-but-still-irritating issue with
rubygems. It installed fine, and i can use gems, but only using
require_gem; using the redefined require (from custom_require.rb)
results in a load error.

--
ryand-ruby@zenspider.com - Seattle.rb - Seattle.rb | Home
http://blog.zenspider.com/ - http://rubyforge.org/projects/ruby2c

Don't confuse the name of the gem (e.g. 'fxruby') with the names of the
include files provide by the gem (e.g. 'fox12')

···

On Sunday 26 June 2005 01:18 am, Joel VanderWerf wrote:

> But:
> irb(main):001:0> require 'fxruby'
> LoadError: No such file to load -- fxruby

Patrick Fernie wrote:
require 'fox12'
works for me, and I have fox installed only as a gem:

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

Ah, this makes sense. Will the patched require eventually load by the
gem library name? This seems a little more natural, but then again I
suppose it leads to the problem of maintaining gemified and
non-gemified versions (whereas using the straight library name
doesn't). I suppose if I had paid more attention to the
documentation/examples provided by the gems I install, this would have
been obvious.

Thanks,
Patrick

···

On 6/28/05, Ryan Davis <ryand-ruby@zenspider.com> wrote:

On Jun 25, 2005, at 3:02 PM, Patrick Fernie wrote:

> I'm having a not-so-critical-but-still-irritating issue with
> rubygems. It installed fine, and i can use gems, but only using
> require_gem; using the redefined require (from custom_require.rb)
> results in a load error.

The difference is that require_gem refers to the gem name and the
patched require does not, it still refers to the library name.
Another example is my gem ParseTree. You can do:

require 'rubygems'
require_gem 'ParseTree' # auto-requires parse_tree
require 'sexp_processor'

Since require_gem can only (currently) auto-require a single library,
if you want sexp_processor, you have to do that with a regular
require. Alternatively, you can leave the gem names out of it:

require 'rubygems' require nil # require for non-gem setups
require 'parse_tree'
require 'sexp_processor'

Either one works fine. I prefer the latter and am switching all my
code to it.

--
ryand-ruby@zenspider.com - Seattle.rb - http://www.zenspider.com/
seattle.rb
http://blog.zenspider.com/ - http://rubyforge.org/projects/ruby2c

Ryan Davis wrote:

require 'rubygems' require nil # require for non-gem setups

Did you mean
require 'rubygems' rescue nil
above?

require 'parse_tree'
require 'sexp_processor'

- alan

···

On Jun 25, 2005, at 3:02 PM, Patrick Fernie wrote:

I hope not.

-austin

···

On 6/28/05, Patrick Fernie <patrick.fernie@gmail.com> wrote:

Ah, this makes sense. Will the patched require eventually load by the
gem library name?

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

Patrick Fernie said:

Ah, this makes sense. Will the patched require eventually load by the
gem library name?

Is the question: Will you eventually be able to specify the gem name in a
require statement? The answer is no.

'require' should always work with files.

Here's some guidlelines:

* Always use a plain 'require' in your code.

* Use 'require_gem' only in code that needs to specify a specific version
of a gem to be used.

* When you do use a 'require_gem', collect the require_gem statements in a
contained area of your code base so that when you need to change what
versions are required, it will be easy to do so.

···

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

Ah, this makes sense. Will the patched require eventually load by the
gem library name? This seems a little more natural, but then again I

No, afaik, it won't. I don't think it is more "natural" either. If anything, require_gem will be renamed to something that conveys the orthogonality better.

suppose it leads to the problem of maintaining gemified and
non-gemified versions (whereas using the straight library name
doesn't). I suppose if I had paid more attention to the
documentation/examples provided by the gems I install, this would have
been obvious.

Oh, I wouldn't go that far. :wink:

···

On Jun 28, 2005, at 7:20 AM, Patrick Fernie wrote:

--
ryand-ruby@zenspider.com - Seattle.rb - Seattle.rb | Home
http://blog.zenspider.com/ - http://rubyforge.org/projects/ruby2c

DOH. Yes. I meant that.

···

On Jun 28, 2005, at 8:16 AM, Alan Chen wrote:

require 'rubygems' require nil # require for non-gem setups

Did you mean
require 'rubygems' rescue nil
above?

--
ryand-ruby@zenspider.com - Seattle.rb - Seattle.rb | Home
http://blog.zenspider.com/ - http://rubyforge.org/projects/ruby2c

Ryan Davis wrote:

require 'rubygems' require nil # require for non-gem setups

Did you mean
require 'rubygems' rescue nil
above?

DOH. Yes. I meant that.

I don't think, that this will work.

irb(main):001:0> LoadError.is_a? StandardError
=> false

···

--
Florian Frank

Florian Frank wrote:

irb(main):001:0> LoadError.is_a? StandardError
=> false

What I really meant to say:

LoadError.ancestors.include? StandardError

···

--
Florian Frank