Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [BUG] RubyGems: "No such file to load -- rubygems/builder"

Reply
Thread Tools

[BUG] RubyGems: "No such file to load -- rubygems/builder"

 
 
Erik Veenstra
Guest
Posts: n/a
 
      02-04-2005
I added some debug information to the require method as defined
by RubyGems, because I didn't trust a message I got ("No such
file to load -- rubygems/builder").

The problem occurs when require is invoked recursively. In the
situation that a LoadError is thrown some levels deep, the file
it complains about ("rubygems/builder") isn't the file that
raised the exception ("yaml", because it's the first "9"-line).
After installing "libyaml-ruby", I got one step further: "zlib"
is missing", and so on. But in all situations, I got the same
message ("No such file to load -- rubygems/builder").

Looks like a bug...

gegroet,
Erik V.

----------------------------------------------------------------

def require(path)
p [1, path]
require__ path
p [2, path]
rescue LoadError
p [3, path]
begin
p [4, path]
@gempath_searcher ||= Gem::GemPathSearcher.new
p [5, path]
if spec = @gempath_searcher.find(path)
p [6, path]
Gem.activate(spec.name, true, "= #{spec.version}")
p [7, path]
require__ path
p [8, path]
else
p [9, path]
raise LoadError, "No such file to load -- #{path}"
end
end
end
end # module Kernel

----------------------------------------------------------------

erik@erikshost:~$ gem install sqlite-ruby
[1, "rubygems/user_interaction"]
[2, "rubygems/user_interaction"]
[1, "rubygems/builder"]
[1, "rubygems/package"]
[1, "yaml"]
[3, "yaml"]
[4, "yaml"]
[5, "yaml"]
[9, "yaml"]
[3, "rubygems/package"]
[4, "rubygems/package"]
[5, "rubygems/package"]
[9, "rubygems/package"]
[3, "rubygems/builder"]
[4, "rubygems/builder"]
[5, "rubygems/builder"]
[9, "rubygems/builder"]
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:35:in
`require': No such file to load -- rubygems/builder (LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems.rb:58:in
`manage_gems'
from /usr/local/bin/gem:4

----------------------------------------------------------------

 
Reply With Quote
 
 
 
 
Austin Ziegler
Guest
Posts: n/a
 
      02-04-2005
On Sat, 5 Feb 2005 03:40:15 +0900, Erik Veenstra <(E-Mail Removed)> wrote:
> I added some debug information to the require method as defined
> by RubyGems, because I didn't trust a message I got ("No such
> file to load -- rubygems/builder").
>
> The problem occurs when require is invoked recursively. In the
> situation that a LoadError is thrown some levels deep, the file
> it complains about ("rubygems/builder") isn't the file that
> raised the exception ("yaml", because it's the first "9"-line).
> After installing "libyaml-ruby", I got one step further: "zlib"
> is missing", and so on. But in all situations, I got the same
> message ("No such file to load -- rubygems/builder").


This is a bug, and I'm not sure the best way to handle this -- but the
real problem is the way that Debian-family Linuxes package Ruby.

-austin
--
Austin Ziegler * http://www.velocityreviews.com/forums/(E-Mail Removed)
* Alternate: (E-Mail Removed)


 
Reply With Quote
 
 
 
 
Eric Schwartz
Guest
Posts: n/a
 
      02-04-2005
Austin Ziegler <(E-Mail Removed)> writes:
> This is a bug, and I'm not sure the best way to handle this -- but the
> real problem is the way that Debian-family Linuxes package Ruby.


Progress is being made; people who are interested in affecting the
process or outcome should join the debian-ruby mailing list
(http://lists.debian.org/), and read the archives, at least for
January.

-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
 
Reply With Quote
 
Erik Veenstra
Guest
Posts: n/a
 
      02-04-2005
> > I added some debug information to the require method as
> > defined by RubyGems, because I didn't trust a message I got
> > ("No such file to load -- rubygems/builder").
> >
> > The problem occurs when require is invoked recursively. In
> > the situation that a LoadError is thrown some levels deep,
> > the file it complains about ("rubygems/builder") isn't the
> > file that raised the exception ("yaml", because it's the
> > first "9"-line). After installing "libyaml-ruby", I got one
> > step further: "zlib" is missing", and so on. But in all
> > situations, I got the same message ("No such file to load
> > -- rubygems/builder").

>
> This is a bug, and I'm not sure the best way to handle this
> -- but the real problem is the way that Debian-family Linuxes
> package Ruby.


I disagree. This example is a result of the strange Ruby
packages on Debian systems. That's true. But the same problem
can occur in other situations as well. The way the require
method of RubyGems catches the LoadError exception is the real
problem.

The solution is really easy... See below. You can use solution
B or C.

gegroet,
Erik V.

----------------------------------------------------------------

$ cat a.rb
class LoadError
end

module Kernel
alias require__ require

def require(path)
require__ path
rescue LoadError => e
begin
if false # No gem found.
else
#raise LoadError, "No such file to load -- #{path}" # A
#raise e # B
raise LoadError, e.message # C
end
end
end
end

puts "A1"
require "b"
puts "A2"

$ cat b.rb
puts "B1"
require "c"
puts "B2"

$ cat c.rb
puts "C1"
require "d" # Doesn't exist.
puts "C2"

$ ruby a.rb
A1
B1
C1
a.rb:15:in `require': No such file to load -- d (LoadError)
from a.rb:22

----------------------------------------------------------------

 
Reply With Quote
 
Austin Ziegler
Guest
Posts: n/a
 
      02-04-2005
On Sat, 5 Feb 2005 06:20:15 +0900, Erik Veenstra
<(E-Mail Removed)> wrote:
>> This is a bug, and I'm not sure the best way to handle this --
>> but the real problem is the way that Debian-family Linuxes
>> package Ruby.

> I disagree. This example is a result of the strange Ruby packages
> on Debian systems. That's true. But the same problem can occur in
> other situations as well. The way the require method of RubyGems
> catches the LoadError exception is the real problem.


It's not the only one. Any time *anything* catches a LoadError, the
real exception can be hidden, which is why I said I'm not sure the
best way to handle this. I faced something similar to this in Ruwiki
(because I have a fairly sophisticated require technique to try to
discover things in various places since Ruwiki can be installed in
multiple fashions), and I'm not sure I'm happy with the result that
I managed there, either.

In part, one might argue that silently catching a LoadError is a bad
thing. In some testing code that I have for Text::Format, I do:

begin
require 'text/hyphen'
hy = Text::Hyphen.new
rescue LoadError
begin
require 'tex/hyphen'
hy = TeX::Hyphen.new
rescue LoadError
print 'S'
return true
end
end

This way, I can exercise the external interfacing of Text::Format
with one of the two available hyphenation libraries -- but I lie to
test/unit in order to do so, sort of. However, if the require of
text/hyphen failed for a reason *other* than text/hyphen not being
installed (e.g., text/hyphen required a library that it currently
doesn't but is broken because of Debian packaging decisions, for
example), this test program would hide that.

As I said, I'm not sure *how* it should deal with this. Perhaps a
variant of LoadError that chains the pieces together, e.g.,

class GemLoadError < LoadError; end

and set it up to keep track of any other LoadError or GemLoadError
caught?

-austin
--
Austin Ziegler * (E-Mail Removed)
* Alternate: (E-Mail Removed)


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MissingSourceFile in <controller not set>#<action not set> - No such file to load -- /config/routes.rb Seth Rasmussen Ruby 3 09-17-2005 12:13 AM
Failed to install Rails No such file to load -- rubygems/security (LoadError) Zoong Pham Ruby 1 08-11-2005 01:39 PM
Ruby: No such file to load -- ubygems (LoadError) Brian Takita Ruby 7 05-24-2005 07:11 PM
Getting error: ..."in 'require': No such file to load -- socket (LoadError) Ruby Ruby Ruby 0 04-22-2004 12:34 PM



Advertisments