Note:
I asked this question when I got unexpected messages when doing bundle install
with the factory_girl
gem using Ubuntu 11.10. Being a noob I had ... and still have ... no idea what was going on. The update below attempts to outline what I did to eventually get rid of the messages. I am leaving the question around with a slightly more pertinent title line in case it might be of use to someone else.
I look at Factory Girl's README.md and I see:
Install gem install factory_girl or add the following line to Gemfile: gem 'factory_girl' and run bundle install from your shell. Supported Ruby versions The Factory Girl 3.x series supports Ruby 1.9.x. For older versions of Ruby, please use the Factory Girl 2.x series.
Since I am currently usingRails 3.1.0
andruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
I add gem 'factory_girl'
to my Gemfile and do bundle update
.
But then continuing on I open the Getting Started.md file and read
Update Your Gemfile If you're using Rails, you'll need to change the required version of factory_girl_rails: gem "factory_girl_rails", "~> 2.0" If you're not using Rails, you'll just have to change the required version of factory_girl: gem "factory_girl", "~> 3.0" Once your Gemfile is updated, you'll want to update your bundle.
OK, fine. I remove gem 'factory_girl'
from my Gemfile and instead addgem "factory_girl_rails", "~> 2.0"
.
I then try bundle update
once again. This time, no joy.
$bundle install Invalid gemspec in [/usr/local/lib/ruby/gems/1.9.1/specifications/ factory_girl_rails-2.0.0.gemspec]: Illformed requirement ["# 3.0.7"] Invalid gemspec in [/usr/local/lib/ruby/gems/1.9.1/specifications/ factory_girl_rails-2.0.0.gemspec]: Illformed requirement ["# 3.0.7"] Fetching source index for http://rubygems.org/ Using rake (0.9.2.2) Using ZenTest (4.7.0) ... a bunch of "Using" lines omitted for brevity ... Using deepopenstruct (0.1.2) Using factory_girl (3.0.0) Installing factory_girl_rails (2.0.0) Invalid gemspec in [/usr/local/lib/ruby/gems/1.9.1/specifications/factory_girl_rails-2.0.0.gemspec]: Illformed requirement ["# 3.0.7"] Using haml (3.1.4) Using jquery-rails (1.0.19) ... a bunch of "Using" lines omitted for brevity ... Using uglifier (1.2.4) Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
So now I'm wondering (1) why following the instructions in the READMEs have apparently not worked and (2) what should I do to my Gemfile in order to get Factory Girl smiling and productive?
Update
While getting error messages which I do not understand is frustrating, getting rid of them but not really being sure what I did to, err, "fix" things is also less special. Oh, well.
In all honesty, though I have been using bundle I had no idea what the difference was between gem
, rvm
, and bundle
nor did I really understand what each command is supposed to do. I think this blog entry I found via Google helped somewhat with that:
RVM and Bundler in Five Seconds
Thinking that rvm and bundle are supposed to automate the management of a group of gems while gem
just manages gems, I looked at the gem commands.
I tried gem check
which IIRC did nothing. I then tried gem cleanup
which came back with a long list of gems it wanted to uninstall. Trusting that I could (probably) get back to where I needed to be by using bundle install
, I let it do the uninstalls. (Though I had to use sudo gem cleanup
because I lacked write permission to some of the directories involved).
After doing this gem check
and gem cleanup
came back clean. However, bundle check
returned:
The following gems are missing * activesupport (3.1.0) * activemodel (3.1.0) * rack-cache (1.0.3) * actionpack (3.1.0) Install missing gems with `bundle install`
So I did both bundle install
followed by (why not?) bundle update
. This installed the gems listed above with no problems. In particular, this time I did not get the Invalid gemspec
or any other error messages. (Hurrah!)
Of course, bundle update
did nothing as, frankly, I was expecting it to do.
So while I'm still not sure what happened, the original reason for my question has been kinda, sorta solved.
I'll leave this question unanswered for a week or so to see if anyone else wants to contribute any comments. After that if no one else provides a more informative answer, I guess I'll just "answer" this question myself to close it out.
Thanks to all who helped nudge me towards a cleaner set of gems.