« AWStats single IP issues with LightTPD / Apache proxy | Back to Main | RailsConf 2006 »

Missing Gems = Strange Rails Errors

I was working on a project for a client yesterday and kept getting a strange error message when I tried to run the unit tests.

I would type in "rake test:units" at the prompt and get the following:

test_helper.rb:18: undefined method `use_transactional_fixtures=' for Test::Unit::TestCase:Class (NoMethodError)

What? How could "use_transactional_fixtures" be undefined? I kept poking around and finally discovered I was missing a Ruby gem required by the project. Strange how it would generate the above error...

Bottom line, make sure you have all of your required gems installed and updated!

Comments

Howdy, I'm having the same problem. Mind sharing which gem you had to install?

If I remember correctly, it was a gem called 'pdf-writer' - but I think this problem could be caused by any required gem that is missing.

Hmm, well I'm not using the PDF writer, so I don't think that's it. How did you figure out which gem was missing?

In my case I had some documentation I was able to look at that listed the required gems. If you look at the "require" statements in your files, that should tell you what libraries you are loading. Some of them are gems. And "gem list --local" will show you what you have installed locally. That's what I would try.

Well, it was indeed a 'require' problem. I tested my code through other means and found that I had a few things out of place - not gems but just regular requires. It is truly strange that you don't get a better error when that happens. Very odd! Might be a good thing to report as a bug…

We ran into this issue -- careful that libs are case sensitive, and failures do not bubble up. In this case one of our requires:

uri should have been URI

This is also common when including Rmagick not rmagick -- crazy!

I'm working on fixing rake to give better error messages for problems like this: http://www.embracingchaos.com/2006/10/misleading_erro.html

Post a comment