1

I got almost the same questions on this stackoverflow postGithub link but both doesn't seem to help in my case . I explain it why. Everything was working very fine on my local machine and heroku test instance then suddenly while i pushed my code on heroku test instance that went away with the message

"Application Error"

i checked the logs and found the error

`require': cannot load such file -- simplecov (LoadError)

complete logs are below

/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in require': cannot load such file -- simplecov (LoadError) from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in block in require' from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:in load_dependency' from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in require' from /app/vendor/bundle/ruby/2.2.0/gems/codeclimate-test-reporter-1.0.1/lib/code_climate/test_reporter/formatter.rb:7:in `'

while my localhost is working fine . I looked into logs more and found that heroku is trying to look simplecov files in rvm ruby 2.2.0 while i have explicitly mentioned 2.2.4 in my gemfile . That seems to be an error cause .I can not downgrade my whole application to 2.2.0 so i tried many solutions like bundle update and removing and reinstalling rspec with simplecov but all in vain . Any help will be greatly appreciating

Update: below is my gemfile test groups

source 'https://rubygems.org'
 ruby "2.3.0"



gem 'therubyracer', :platforms => :ruby
gem 'rails', '4.2.5.1'
gem 'pg'
gem 'devise'
gem 'will_paginate'
gem 'will_paginate-bootstrap'
gem 'stripe'
# Required for functioning assets on Heroku
gem 'rails_12factor', group: :production

gem "has_permalink"
#gem 'delayed_job_active_record'
# Development
group :development, :test do
  gem 'mailcatcher'
  gem 'dotenv-rails'
  gem 'byebug'
  gem 'database_cleaner', '~> 1.5.0'
  #gem 'webmock', '~> 1.21.0'
end

gem 'tzinfo-data'
gem 'bcrypt', '~> 3.1.10'
gem 'uglifier', '>= 1.3.0'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '>= 3.2'
gem 'sprockets-rails'
gem 'bootstrap-select-rails'

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

#gem 'sorcery'

gem 'bourbon'
gem 'neat'
gem 'font-awesome-rails'

gem 'wicked'
gem 'spring',        group: :development

group :test do
  gem 'rspec'
  gem 'rspec-rails'
  gem 'rspec-instafail', require: false
  gem 'guard-rspec', require: false
  gem 'vcr'
  gem 'capybara'
  gem 'launchy'
  gem 'selenium-webdriver'
  gem 'simplecov', '~> 0.12.0'
end


gem 'mandrill-api'
gem 'carrierwave'
gem 'fog'
gem 'rmagick'
gem 'puma'
gem 'jquery-ui-rails'
gem 'codeclimate-test-reporter'

gem 'momentjs-rails', '>= 2.9.0'
gem 'bootstrap3-datetimepicker-rails', '~> 4.17.42'
gem 'bootstrap-wysihtml5-rails', github: 'nerian/bootstrap-wysihtml5-rails'

gem 'aws-sdk', '< 2.0'
gem 'aws-s3'
gem 'fog-aws'

gem 'shash'
gem 'listen'

I ran the following commands

rm Gemfile.lock
bundle install 
heroku run rails c

and above mentioned error appears

Community
  • 1
  • 1
Mani
  • 2,391
  • 5
  • 37
  • 81
  • 1
    The `2.2.0` shouldn't be the issue. It's assumed that all gems in the `2.2.x` Ruby family are shared (the last tiny version number is a bug correction patch and doesn't effect the gems)... EDIT: this means that Ruby `2.2.4` gems are often (and should be) installed in a subfolder with the `2.2.0` name - unless I'm missing something, your question doesn't have full details. – Myst Nov 08 '16 at 08:00
  • Are you running it through bundler? That means that your are either running rspec with `bundle exec rspec` or though a binstub `bin/rspec`. You can generate a binstub by running `bundle binstub rspec-core` or by using the [spring-commands-rspec](https://github.com/jonleighton/spring-commands-rspec) gem and running `bin/spring binstub rspec`. – max Nov 08 '16 at 08:40
  • @Myst that's all logs are showing . kindly let me know what information will make question more suitable - thanks – Mani Nov 08 '16 at 09:11
  • @max no dear , i'm not running it through bundler . I'm trying to run command `heroku run rails c` and it give me that error – Mani Nov 08 '16 at 09:16
  • update your gemfile `gem 'simplecov', '~> 0.12.0', require: false` and use it only on your test suite when required. like you can require it on your on `spec_helper.rb` .. like this `require 'simplecov'; SimpleCov.start 'rails'`. – sa77 Nov 08 '16 at 09:58

1 Answers1

3

SimpleCov is a code coverage tool which is intended to be run on your local machine or a CI such as Travis CI. It should not be run on Heroku which is for production or staging.

You should place simple_cov and any test related gems in the test group of your gemfile:

group :test do
  gem 'simplecov', '~> 0.12.0'
end

Run bundle to regenerate the Gemfile.lock and commit the result. Redeploy the application to Heroku by pushing the changes.

Update

Your Gemfile has gem 'codeclimate-test-reporter' outside the test group. Which is causing this error. You also have listen which is also a tool which is not suited for production.

All the gems that are required in all environments should be placed at the top of the Gemfile, then list the groups.

Prefer placing gems in group blocks over using the group option. In general be more careful when adding dependencies and don't let your Gemfile become a mess because thats how you get these issues in the first place.

source 'https://rubygems.org'
ruby "2.3.0"

gem 'rails', '4.2.5.1'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] # Only needed on Windows and jRuby
gem 'puma' # You should have a version constraint here!!!

## == DB/ORM ===== 
gem 'pg' # You should have a version constraint here!!!
gem "has_permalink"
#gem 'delayed_job_active_record'

## == Authentication ====
gem 'devise'
gem 'bcrypt', '~> 3.1.10'

## == Front-End ====
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'uglifier', '>= 1.3.0'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '>= 3.2'
# ---- gem 'sprockets-rails' not needed since about rails 4.0
gem 'bootstrap-select-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
gem 'momentjs-rails', '>= 2.9.0'
gem 'bootstrap3-datetimepicker-rails', '~> 4.17.42'
gem 'bootstrap-wysihtml5-rails', github: 'nerian/bootstrap-wysihtml5-rails'
gem 'bourbon'
gem 'neat'
gem 'font-awesome-rails'
gem 'wicked'

## == Image uploads ====
gem 'carrierwave'
gem 'rmagick'

## == API's ====
gem 'mandrill-api'
# can most likely be removed as its a dependency of one of your gems.
gem 'fog' 
gem 'stripe'

## == Misc ====
gem 'will_paginate'
gem 'will_paginate-bootstrap'
#gem 'sorcery'

group :development, :test do
  gem 'mailcatcher' # Don't add to gemfile. Read the readme
  gem 'dotenv-rails'
  gem 'byebug'
  gem 'spring'
  # rspec-rails depends on rspec so you dont need to list it
  # it should be in the development group as well so that the generators work.
  gem 'rspec-rails'
  gem 'therubyracer', :platforms => :ruby # heroku has its own JS runtime.
end

group :test do
  gem 'rspec-instafail', require: false
  gem 'guard-rspec', require: false
  gem 'vcr'
  gem 'capybara'
  gem 'launchy'
  gem 'selenium-webdriver'
  gem 'simplecov', '~> 0.12.0'
  gem 'webmock', '~> 1.21.0' # don't use in development!
  gem 'database_cleaner', '~> 1.5.0' # don't use in development! 
  gem 'codeclimate-test-reporter' # This was the gem that was breaking your development server.
end

group :production do
  gem 'rails_12factor'
end
Community
  • 1
  • 1
max
  • 96,212
  • 14
  • 104
  • 165
  • Make sure any test or development gems like rspec, spring, database_cleaner, pry, minitest etc are not in the default group (not nested in the group) or in the production group. You can get a list of the gems required by your gemfile by using `heroku run bundle show`. Use https://rubygems.org to read up on what each gem does. Your production environment should only have the bare minimum of gems required to actually run the application. – max Nov 08 '16 at 09:41
  • though my gem was already in test group but i added it in seperate test group too as it is mentioned here but no use . still the same error – Mani Nov 08 '16 at 09:45
  • Add your gemfile to your question please. – max Nov 08 '16 at 09:48
  • @ImranNaqvi , did you delete the `gemfile.lock` file, run `bundle install` and recommit? – Myst Nov 08 '16 at 09:54
  • i didn't deleted lock file . but i do it now – Mani Nov 08 '16 at 09:55
  • still no use :( – Mani Nov 08 '16 at 10:33
  • You need to edit your question with a complete verifiable example. We can't help you debug through comments. Its a waste of time. – max Nov 08 '16 at 10:35
  • i understand you but i don't know what i'm missing – Mani Nov 08 '16 at 10:35
  • Start with the entire gemfile. And add the exact steps you took leading up to the error. – max Nov 08 '16 at 10:37
  • For example the stacktrace tells us that `codeclimate-test-reporter` is being loaded on heroku which means that something is still very wrong – max Nov 08 '16 at 10:38
  • If you recently discovered the error try [rolling back the heroku app](https://devcenter.heroku.com/articles/releases) and finding the error by looking at the git changelog from the last working commit. – max Nov 08 '16 at 10:42