Installing Factory Girl 3.3 with bundle results in Ruby Version error

factory-bot, rbenv, ruby, ruby-on-rails, rubygems

Solution

The problem isn't that `rbenv` isn't working or is conflicting with anything, it's that you simply aren't actually set up to use it correctly.

The first thing I noticed is that your `gem` install location is in:

/usr/lib/ruby/vendor_ruby

with gem executables in:

/usr/bin

This would appear to be a "system ruby" as provided by the `Ubuntu 12.04` `ruby` package, installed when you do:

sudo apt-get install ruby

So, even though you've got `rbenv` installed, you're not actually using it and attempts to install gems are failing. Specifically, the ruby you're actually running is the Ubuntu system ruby version `1.8.7`, as evidenced by this line:

/usr/lib/ruby/vendor_ruby/1.8/rubygems/installer.rb:388:in `ensure_required_ruby_version_met': factory_girl requires Ruby version >= 1.9.2. (Gem::InstallError)

In short, the error is telling you exactly what the problem is - `factory_girl` requires ruby `1.9.2` or above and you're not running a new enough version.

So, to fix the problem, you need to configure your "dot files" (`~/.bash_profile`, `~/.bashrc`, etc.) as per the `rbenv` install instructions so that when you type `ruby` or `gem`, or any of your rubygems executable commands, such as `rake` or `bundle` that you're actually running your `rbenv` managed ruby and not a default, system-provided ruby. This is ultimately accomplished by having your `rbenv` "shims" directory (`~/.rbenv/shims`) in your path before your usual `$PATH` directories (and by remembering to run `rbenv rehash` after you install new ruby version or new gems).

Then, once you've configured `rbenv` it correctly, you can take advantage of `.rbenv-version` files in directories as created with the `rbenv local` command.

Problem

I am installing factory girl with bundle install on Ubuntu 12.04 64bit and am getting the error ``` Installing factory_girl (3.3.0) /usr/lib/ruby/vendor_ruby/1.8/rubygems/installer.rb:388:in `ensure_required_ruby_version_met': factory_girl requires Ruby version >= 1.9.2. (Gem::InstallError) from /usr/lib/ruby/vendor_ruby/1.8/rubygems/installer.rb:156:in `install' from /usr/lib/ruby/vendor_ruby/bundler/source.rb:101:in `install' from /usr/lib/ruby/vendor_ruby/bundler/rubygems_integration.rb:78:in `preserve_paths' from /usr/lib/ruby/vendor_ruby/bundler/source.rb:91:in `install' from /usr/lib/ruby/vendor_ruby/bundler/installer.rb:58:in `run' from /usr/lib/ruby/vendor_ruby/bundler/rubygems_integration.rb:93:in `with_build_args' from /usr/lib/ruby/vendor_ruby/bundler/installer.rb:57:in `run' from /usr/lib/ruby/vendor_ruby/bundler/spec_set.rb:12:in `each' from /usr/lib/ruby/vendor_ruby/bundler/spec_set.rb:12:in `each' from /usr/lib/ruby/vendor_ruby/bundler/installer.rb:49:in `run' from /usr/lib/ruby/vendor_ruby/bundler/installer.rb:8:in `install' from /usr/lib/ruby/vendor_ruby/bundler/cli.rb:222:in `install' from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/task.rb:22:in `send' from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/task.rb:22:in `run' from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/invocation.rb:118:in `invoke_task' from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor.rb:246:in `dispatch' from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/base.rb:389:in `start' from /usr/bin/bundle:13 ``` Here is my Ruby -v ``` ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] ``` I am using RBenv, here is the results of command: rbenv version ``` 1.9.3-p194 (set by /home/user/.rbenv/version) ``` here is the results of command: rbenv versions ``` 1.9.2-p290 * 1.9.3-p194 (set by /home/user/.rbenv/version) ``` Here is factory_girl_rails in my gemfile ``` group :test do gem 'factory_girl_rails', '~> 3.3.0' end ``` Let me know if you need to see any more files i'll gladly post them. Anyone have any idea why I

Original source