3
votes

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 using
Rails 3.1.0 and
ruby 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 add
gem "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.

4
The first red flag here is that you say you're using ruby 1.9.2, but the stack track shows 1.9.1. Are you using rvm? What OS is this? How was ruby installed?jdl
Sounds like this question might be about the same thing - stackoverflow.com/questions/9004804/…Nate
@jdl Ruby 1.9.1, .2, and .3 all use 1.9.1 as the path: stackoverflow.com/a/6352310/424300Dylan Markow
Since you're using bundler, running "gemset empty" isn't a big deal. I do question the use of "sudo rvm" on a dev box though. Usually you would want to install rvm without requiring root access.jdl
You received a "Your bundle is complete!" -- so I don't think there is a problemJesse Wolgamott

4 Answers

7
votes

I ran into pretty much the same problem when trying to install the factory_girl_rails gem and was able to resolve it by removing the offending specifications file and then running

gem update --system

followed by

bundle install

1
votes

There is apparently some errors generated in the gemspec. Open it and remove the shitty bits!

personally I did it using vim like so:

vim ~/.rvm/gems/ruby-1.8.7-p357/specifications/factory_girl_rails-1.7.0.gemspec
:%s/".*YAML.*\ /"/
:wq

then re bundle

and the problem should be solved !

1
votes

With ruby 1.8.7 and factory_girl_rails you can pin the version of factory_girl to 2.6 and let bundler do the rest.

gem 'factory_girl', '~> 2.6'
gem "factory_girl_rails"

Worked for me.

0
votes

There is no point that I can see in keeping this question open any longer. While I never did clearly understand why I was getting Invalid gemspec, the steps which are listed in my update to my question "solved" that "problem".

It would be nice if there was a way to simply close a question as "An answer is no longer a priority for me" or even simply "I've moved on". But there isn't. This "answer" will at least take this question off the list of things to still be looked at.