RubyGems bug bit me.

by Gregory Brown

UPDATE: The bug mentioned below is probably harmless in your applications. My issue was actually with some dependencies who were fighting each other, and not with the bug mentioned below. However, if you are annoyed about gems returning false when you require them, feel free to read below how to fix it.

UPDATE2: The bug in one of Ruport's example programs (Ruport itself never actually requires active_record), was that Transaction::Simple is included in a vendor dir of ActiveRecord and is required via gems in PDF::Writer, so they clash, dumping a few warnings. I'm not sure if this will have any side effects or not.

"If there were any more hurdles on this track, the thing would be made out of hurdles"

For those who have been following Ruport development, you know that I've gone through 4 computers in the last 5 weeks. That's insane. But now, as I finally have had a chance to spend a few hours on a machine without it's hardware breaking on me, I've run into software issues.

The current stable version of RubyGems (0.8.11) does not correctly load gems which use the auto_require feature.

So in the course of Ruport development, i found require 'lafcadio' and require 'redcloth' returning big fat falses on me! (Which was causing unsavory results elsewhere in the system)

Searching RubyTalk, Jim Weirich mentioned that it had been fixed in the CVS head.
Sure enough, it was.

I deleted all of the rubygems stuff from my ruby and site_ruby dirs, and then ran:

cvs -d :pserver:anonymous@rubyforge.org:/var/cvs/rubygems login
cvs -d :pserver:anonymous@rubyforge.org:/var/cvs/rubygems checkout rubygems
cd rubygems
sudo ruby setup.rb

I had to reinstall my gems, but once I did, I was back to getting trues instead of falses ;)

Now I have no clue how stable the CVS head is, so this is not a recommendation, but rather just a little experience I wanted to share :)

The good news is, I am back to coding... so those of you out there on the Ruport mailing list, be on the lookout for a beta preview of Ruport in the next day or two.

Thanks to the RubyGems team for quickly fixing this bug so that people who want to be on the bleeding edge rather than downgrading can do so :)

2 Comments

Jim Weirich
2006-01-24 03:54:17
While a bug, it always struck me as a rather innocuous one. Depending on whether require returns true or false seems a bit fragile, as any change in the dependency structure of the libraries could cause a require that formally returned true to be false (i.e. a library gets loaded earlier than expected). MOst people discover the bug during an interactive irb session where the return value of require is shown explicitly.


I'm curious to know what kind logic you are using that depends on a true result from require. Thanks. I'm just trying to understand how people use the rubygems libraries.

Gregory Brown
2006-01-24 11:06:32
> I'm curious to know what kind logic you are using that depends on a true
> result from require. Thanks. I'm just trying to understand how people use the > rubygems libraries


Actually, now that I look at it... nothing.
Ruport has a lot of optional dependencies, but of course I'm not using the true/false to test for it, i'm rescuing LoadError's


I had thought that this auto_require bug was to blame for a bunch of warnings I was getting when combining some libraries together. (I.e. activerecord and lafcadio)


Sure enough, even on CVS, i'm getting a bunch of 'already defined' errors.
The reason why this went away yesterday was because I had not yet reinstalled activerecord.


But now, it's stomping all over pdf/writer and lafcadio again, which has nothing to do with the true/false bug.


Ick. And I thought I fixed something :(


I will update the article to mention this.