3

Background

I am maintaining the content of a Ruby On Rails site, but I really have no experience with Rails.

When trying to run the Rails server: rails s I get this:

Could not find activesupport-3.2.0 in any of the sources

Run bundle install to install missing gems

I run bundle install

Gem::InstallError: factory_girl requires Ruby version >= 1.9.2. An error occured while installing factory_girl (3.2.0), and Bundler cannot continue.

Make sure that gem install factory_girl -v '3.2.0' succeeds before bundling.

Okay, I install factory_girl as per the instructions:

Successfully installed factory_girl-3.2.0 1 gem installed

Run bundle install again:

Gem::InstallError: factory_girl requires Ruby version >= 1.9.2. An error occured while installing factory_girl (3.2.0), and Bundler cannot continue. Make sure that gem install factory_girl -v '3.2.0' succeeds before bundling.

Do you have any idea?

Info

Yesterday I got a cross-tread error when trying to run rails server. So as per this SO advice I advice I've nuked RVM and installed rbenv and bundler instead of RVM.

I have tried with both Ruby 1.9.3-p125 and 1.9.3-rc1

Output of gem list shows factory_girl as installed.

  • ...
  • factory_girl (3.2.0)
  • ...

Output of gem environmentshows the problem might has something todo with ruby 1.9.1 being installed also?

RubyGems Environment:
- RUBYGEMS VERSION: 1.8.10
- RUBY VERSION: 1.9.3 (2011-09-23 patchlevel -1) [x86_64-darwin11.3.0]
- INSTALLATION DIRECTORY: /Users/andreas/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /Users/andreas/.rbenv/versions/1.9.3-rc1/bin/ruby
- EXECUTABLE DIRECTORY: /Users/andreas/.rbenv/versions/1.9.3-rc1/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-11
- GEM PATHS:
- /Users/andreas/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1
- /Users/andreas/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- http://rubygems.org/

halfer
  • 19,824
  • 17
  • 99
  • 186
Andreas
  • 6,612
  • 14
  • 59
  • 69
  • Which ruby version do you get when entering in terminal: ruby -v – Hoetmaaiers May 02 '12 at 12:44
  • I think your ruby is 1.9.1.... => /Users/andreas/.gem/ruby/1.9.1 – stfcodes May 02 '12 at 13:12
  • @RobinH I get: ruby 1.9.3dev (2011-09-23 revision 33323) [x86_64-darwin11.3.0] – Andreas May 02 '12 at 13:17
  • @shuriu - I don't think so - see above... – Andreas May 02 '12 at 13:19
  • can I just delete: - /Users/andreas/.gem/ruby/1.9.1? – Andreas May 02 '12 at 13:20
  • Really confused: `ls /Users/andreas/.gem/ruby` outputs a "1.8" dir - no 1.9.1 in sight? – Andreas May 02 '12 at 13:22
  • @jdoe you are referring to the specific projects `Gemfile.lock`? When I remove it and run `bundle check`, I get the same song unsatisfied dependencies. I am asked to do a `bundle install`. Which I do and TADAAA - no problem... Please explain you magic and let me give you some karma. – Andreas May 02 '12 at 13:33
  • @BenMiller Thanks - but it seems the problem was `Gemfile.lock`. – Andreas May 02 '12 at 13:36
  • try not `rails s` but `bundle exec rails s` – Jakub Oboza May 02 '12 at 14:02
  • @shuriu That `1.9.1` doesn't really correspond to the version of Ruby - see http://stackoverflow.com/questions/8564210/why-are-we-installing-ruby-1-9-2-1-9-3-gems-into-a-1-9-1-folder – Gareth May 02 '12 at 14:03
  • @jdoe please come and collect karma points by provinding your comment as an aswer. The I will mark it as "accepted". Thanks again. – Andreas May 06 '12 at 09:01

5 Answers5

3

Try reinstalling all the gems with the following command:

bundle install --redownload
Iulian Onofrei
  • 9,188
  • 10
  • 67
  • 113
Min San
  • 131
  • 1
  • 5
2

Have you tried this?

bundle exec rails s
Peter O.
  • 32,158
  • 14
  • 82
  • 96
Jakub Oboza
  • 5,291
  • 1
  • 19
  • 10
2

@jdoe answered in the comments. And it worked. Apparently I needed to delete Gemfile.lock.

I don't know why or how though. I am just posting this here, until @jdoe shows up and collects his points with a real answer.

Andreas
  • 6,612
  • 14
  • 59
  • 69
0

First things first - I have no experience with rbenv.

One of the nice things with RVM is that it helps make fairly explicit what the moving parts of your Ruby environment are.

rvm list will give you a list of Rubies rvm gemset list will give you a list of gemsets (this should not be necessary if using bundler)

Now, here are a few tricky things:

  • Gemfile is used by Bundler to determine what to install
  • If nothing is specified, Bundler will try to install the latest version of a gem
  • If the latest version of a gem is not compatible with your current Ruby, then ...
    • You can change version of Ruby (rvm install 1.9.3 for instance)
    • You can tell the Gemfile to specify which version of the gem you want, with varying degrees of strictness.
      • Can you tell I like indenting bullet points?
      • gem "vcr", "~> 1.11.3" # => this will say you prefer 1.11.3 but anything within 1.11 range is acceptable
      • gem 'factory_girl', '3.2.0' # => this says, only install version 3.2.0 of factory_girl, nothing else

In addition, before anything else, you should run bundle check to see what bundler has to say about your gems.

Trevoke
  • 4,115
  • 1
  • 27
  • 48
0

Make sure all the gems you are installing is in the Gemfile, because if the gem is not added to the Gemfile, even if you installed it manually, your Rails app is not getting it.

Sample Gemfile would be

gem 'rails', '3.0.0'

gem 'mysql2', '< 0.3'
gem 'rails3-jquery-autocomplete'

#authorization
gem 'authlogic'
gem 'hoptoad_notifier'

#reporting
gem 'lazy_high_charts'

group :test do
  gem 'rspec', '2.0.0'
  gem 'rspec-rails', '2.0 '
  gem "test-unit"
end
halfer
  • 19,824
  • 17
  • 99
  • 186
sameera207
  • 16,547
  • 19
  • 87
  • 152