Как разрешить конфликт зависимостей гемов после установки email_spec

Я только что установил email-spec для использования с rspec в соответствии с инструкциями в readme. Теперь, когда я пытаюсь запустить тест (даже без использования методов email-spec в моих спецификациях), я получаю эту ошибку:

$ rspec spec
Neither Pony nor ActionMailer appear to be loaded so email-spec is requiring ActionMailer.
WARN: Unresolved specs during Gem::Specification.reset:
      launchy (~> 2.1)
      builder (~> 3.1)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
/Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:34:in `block in setup': You have already activated minitest 5.4.0, but your Gemfile requires minitest 4.7.5. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:19:in `setup'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.7.4/lib/bundler.rb:121:in `setup'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.7.4/lib/bundler/setup.rb:7:in `<top (required)>'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:128:in `require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:39:in `require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
    from /Users/jpalmieri/workspace/blocitoff/config/boot.rb:4:in `<top (required)>'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
    from /Users/jpalmieri/workspace/blocitoff/config/application.rb:1:in `<top (required)>'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
    from /Users/jpalmieri/workspace/blocitoff/config/environment.rb:2:in `<top (required)>'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
    from /Users/jpalmieri/workspace/blocitoff/spec/rails_helper.rb:4:in `<top (required)>'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
    from /Users/jpalmieri/workspace/blocitoff/spec/features/mark_todo_complete_spec.rb:1:in `<top (required)>'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:241:in `load'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:241:in `block in load'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:241:in `load'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `each'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:96:in `setup'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84:in `run'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in `run'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.1.7/exe/rspec:4:in `<top (required)>'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/bin/rspec:23:in `load'
    from /Users/jpalmieri/.rbenv/versions/2.0.0-p353/bin/rspec:23:in `<main>'

Предварение bundle exec заставит тесты работать нормально (я все еще получаю Neither Pony nor ActionMailer appear to be loaded so email-spec is requiring ActionMailer обратите внимание, но я думаю, что это тема для другого поста).

Вот мой Gemfile. Я явно не вызываю minitest, поэтому я предполагаю, что это зависимость email_spec и чего-то еще.

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.10'

gem 'devise'
gem 'figaro', '1.0'
gem 'bootstrap-sass', '~> 3.3.1'
gem 'timecop'
gem 'pundit'

group :development, :test do
  gem 'rspec-rails'
  gem 'capybara'
end

# Use sqlite3 as the database for Active Record
group :production do
  gem 'pg'
  gem 'rails_12factor'
end

group :development do
  gem 'sqlite3'
end

group :test do
  gem 'factory_girl_rails', '~> 4.0'
  gem 'database_cleaner'
  gem 'email_spec'
end

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.2'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# 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'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

Я попытался разрешить конфликт, добавив gem 'minitest', '~> 4.7.5' к моему :test группа, но все равно получаю ту же ошибку.

group :test do
  gem 'factory_girl_rails', '~> 4.0'
  gem 'database_cleaner'
  gem 'email_spec'
  gem 'minitest', '~> 4.7.5'
end

Мои вопросы:

1) мне никогда не приходилось готовить bundle exec до. Должен ли я попытаться разрешить конфликт вместо того, чтобы предвосхищать bundle exec?

2) Если "да" на вопрос 1, как бы я поступил так?

1 ответ

Решение

Это происходит потому, что Gem указывает в своих зависимостях более старую версию MiniTest, и в вашей системе установлена ​​более новая версия.

С помощью bundle exec это правильный путь. Пожалуйста, смотрите ниже:

При запуске исполняемого файла ВСЕГДА используйте bundle exec [command]. Цитирование из документации к комплектовщику: в некоторых случаях запуск исполняемых файлов без комплекта exec может работать, если исполняемый файл установлен в вашей системе и не извлекает какие-либо гемы, конфликтующие с вашим комплектом. Однако это ненадежно и является источником значительной боли.

http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/

Другие вопросы по тегам