RubyGems Issue

P

Patrick Fernie

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
 
J

Joel VanderWerf

Patrick said:
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.)
 
J

Jim Weirich

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

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')
 
R

Ryan Davis

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.
 
P

Patrick Fernie

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
 
A

Austin Ziegler

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

I hope not.

-austin
--=20
Austin Ziegler * (e-mail address removed)
* Alternate: (e-mail address removed)
 
A

Alan Chen

Ryan said:
On Jun 25, 2005, at 3:02 PM, Patrick Fernie 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
 
J

Jim Weirich

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.
 
R

Ryan Davis

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. ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top