`require':无法加载这样的文件 - simplecov(LoadError)

时间:2016-11-08 07:41:16

标签: ruby-on-rails ruby ruby-on-rails-4 heroku

我对stackoverflow post Github link提出了几乎相同的问题,但在我的案例中似乎都没有帮助。我解释原因。 一切都在我的本地机器和heroku测试实例上工作得非常好,然后突然我将代码推送到带有消息的heroku测试实例上

  

“应用程序错误”

我检查了日志并发现了错误

  

`require':无法加载此类文件 - simplecov(LoadError)

完整的日志在

之下
  

/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in    NONE TOTAL, NOT SPECIFIED ALL CLASSES WINTER SPRING, (EXCL DURUM) ALL CLASSES IRRIGATED IRRIGATION METHOD NON-IRRIGATED IRRIGATION STATUS 阻止在'来自'   /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240: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 需要'来自   /app/vendor/bundle/ruby/2.2.0/gems/codeclimate-test-reporter-1.0.1/lib/code_climate/test_reporter/formatter.rb:7:in   `'

而我的load_dependency' from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in 工作正常。我查看了更多日志,发现heroku正试图在localhost中查看simplecov文件,而我在我的gemfile中明确提到了rvm ruby 2.2.0。这似乎是一个错误原因。我无法将整个应用程序降级到2.2.4,因此我尝试了许多解决方案,例如2.2.0,并删除并重新安装bundle update rspec但所有徒劳。任何帮助都会非常感激

更新: 下面是我的gemfile测试组

simplecov

我运行了以下命令

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'
出现

和上述错误

1 个答案:

答案 0 :(得分:3)

SimpleCov是一种代码覆盖工具,可以在本地计算机或CI(如Travis CI)上运行。它不应该在用于生产或分期的Heroku上运行。

您应该将simple_cov和任何与测试相关的宝石放在gemfile的test组中:

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

运行bundle以重新生成Gemfile.lock并提交结果。 通过推送更改将应用​​程序重新部署到Heroku。

更新

您的Gemfile在测试组之外有gem 'codeclimate-test-reporter'。这导致了这个错误。您还有listen,这也是一个不适合生产的工具。

所有环境中所需的所有gem都应放在Gemfile的顶部,然后列出组。

首选使用group选项将宝石置于组块中。一般来说,在添加依赖项时要更加小心,不要让你的Gemfile变得一团糟,因为这就是你最初如何解决这些问题。

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