Rails 3 Migration expecting test gems to be installed??

Hi,

I have gem file set up so only the specific gems are installed/needed for each environment, so all the test gems like cucumber etc are grou[ed in test. When i try a rake db:migrate RAILS_ENV=staging on the staging server however i get an error saying XXXX gem is not installed, please use bundle install. I dont want the test gems installed on this server however when i run the migration on staging its expecting them to be installed.

Anyone hit this problem before and how did you sort it, i cant find anything in the forums?

JB

Hi,

I have gem file set up so only the specific gems are installed/needed for each environment, so all the test gems like cucumber etc are grou[ed in test. When i try a rake db:migrate RAILS_ENV=staging on the staging server however i get an error saying XXXX gem is not installed, please use bundle install. I dont want the test gems installed on this server however when i run the migration on staging its expecting them to be installed.

Anyone hit this problem before and how did you sort it, i cant find anything in the forums?

Could you post your Gemfile and the error you're getting? It might be in the way the Gemfile is written. Also, make sure that whatever gem is failing is not being required some where else in your app.

B.

thanks,

my gem file is:

source 'http://rubygems.org'

gem 'rails', '3.0.3' gem 'omniauth' gem 'pg', :require => 'pg' gem 'devise' gem 'cancan' gem 'haml' gem 'hpricot' gem 'ruby_parser' gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git' gem 'acts-as-taggable-on' gem 'jquery-rails' gem "will_paginate", "~> 3.0.pre2" gem 'factory_girl_rails' gem "paperclip", "~> 2.3" gem 'formtastic', '~> 1.2.0' gem 'sunspot_rails', '1.2.1' gem 'omniauth' gem 'fb_graph' gem 'recaptcha', :require => 'recaptcha/rails' gem "friendly_id", "~> 3.2.1"

group :development do   gem "nifty-generators" end

group :test do     gem 'test-unit'     gem "shoulda"     gem "rspec-rails", "2.0.0.beta.12"   gem 'cucumber-rails'   gem 'pickle'   gem 'capybara'   gem 'database_cleaner'   # gem 'webrat'     # gem 'webrat', '>=0.7.2.beta.6', :git => 'git://github.com/ orangewise/webrat.git'     gem 'capybara'   gem 'factory_girl_rails'     gem 'ZenTest'   gem 'redgreen'   gem 'autotest-rails'   gem 'autotest'   gem 'autotest-fsevent'   gem 'autotest-growl'   gem 'autotest-notification'   gem "email_spec"   gem "launchy"   gem "Selenium"   gem "selenium-client"   gem "database_cleaner"   gem 'mongrel', '>= 1.2.0.pre2'     gem "fakeweb", ">= 1.2.5" end

When i do a rake db:migrate RAILS_ENV=staging

Could not find autotest-fsevent-0.2.4 in any of the sources Try running `bundle install`.

Baffling!

I wish I had a hard-and-fast answer for you Johnny, but one question that comes to mind: is the staging environment somehow "inheriting" settings from your test environment?

Hi,

I have gem file set up so only the specific gems are installed/needed for each environment, so all the test gems like cucumber etc are grou[ed in test. When i try a rake db:migrate RAILS_ENV=staging on the staging server however i get an error saying XXXX gem is not installed, please use bundle install. I dont want the test gems installed on this server however when i run the migration on staging its expecting them to be installed.

Anyone hit this problem before and how did you sort it, i cant find anything in the forums?

did you run bundle install --without test --without development

Some gems (like rspec) used to generate rake files that required rspec to be loaded, so when rails tried to load your rake tasks it would fail if those gems weren't there anymore. They don't anymore though, now that everyone has figured out the sensible ways of working with bundler - I'd try using a current versions of those gems and clearing out any unneeded rake task files.

Fred

Yes i did bundle install --without test and that worked fine, when i try the db migrate for staging i get the error, i could install all the gems as you say rspec is needed for other stuff possibly but the actual error for the autotest gem is because its specific to mac, the staging site is on linux. From reading the docs it seems to suggest that bundler will know what OS you are on and install the appropriate gem. The whole point of the grouping should be exactly for this reason, i shouldnt have to install test/dev gems on the staging/production server.

Maybe its something silly im doing but but i can see what.....

Yes i did bundle install --without test and that worked fine, when i

try the db migrate for staging

i get the error, i could install all the gems as you say rspec is

needed for other stuff possibly but

the actual error for the autotest gem is because its specific to mac,

the staging site is on linux. From reading

the docs it seems to suggest that bundler will know what OS you are on

and install the appropriate gem. The whole point of

the grouping should be exactly for this reason, i shouldnt have to

install test/dev gems on the staging/production server.

Maybe its something silly im doing but but i can see what…

You didn’t happen to move over your Gemfile.lock from your mac to your staging server did you? If you did, try deleting that file and running the command again.

B.

Aha thanks, i knew it would be something silly. The docs do suggest adding the gemfile.lock to your repository but based on this evidence thats not a good idea. I will need to find out how to manage this when deploying, do you add the production gemfile.lock to the repo........

Aha thanks, i knew it would be something silly. The docs do suggest adding the gemfile.lock to your repository but based on this evidence thats not a good idea. I will need to find out how to manage this when deploying, do you add the production gemfile.lock to the repo........

I've never had to do this (and I seen to have many of the test gems you do (rspec , cucumber etc)

Fred

Aha thanks, i knew it would be something silly. The docs do suggest

adding the gemfile.lock

to your repository but based on this evidence thats not a good idea.

I will need to find out how to

manage this when deploying, do you add the production gemfile.lock to

the repo…

I’ve never had to do this (and I seen to have many of the test gems you do (rspec , cucumber etc)

Fred

I suspected that your Gemfile.lock was set to the dev/test environment on your system and therefore was not set for the staging environment that you wanted it to be. Even though you said to run it in staging, Rails saw a Gemlock.file and checked that before executing the Gemfile.

B.