【问题标题】:ruby on rails 5.0.0.2 incompatible and conflict with gem mongoidruby on rails 5.0.0.2 不兼容并与 gem mongoid 冲突
【发布时间】:2016-02-22 14:31:32
【问题描述】:

红宝石版本 2.3.0

rails 版本 5.0.0.beta2

**GEMFILE **

    source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '>= 5.0.0.beta2', '< 5.1'
#mongoid gem
gem 'mongoid', '~> 5.1.0'
# Use Puma as the app server
gem 'puma'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/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', '~> 2.0'
# Action Cable dependencies for the Redis adapter
gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end
group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 3.0'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

运行捆绑安装后我看到:

Bundler could not find compatible versions for gem "activemodel":
  In snapshot (Gemfile.lock):
    activemodel (= 5.0.0.beta2)

  In Gemfile:
rails (< 5.1, >= 5.0.0.beta2) was resolved to 5.0.0.beta2, which
depends on
activerecord (= 5.0.0.beta2) was resolved to 5.0.0.beta2, which
depends on
        activemodel (= 5.0.0.beta2)

rails (< 5.1, >= 5.0.0.beta2) was resolved to 5.0.0.beta2, which
depends on
activerecord (= 5.0.0.beta2) was resolved to 5.0.0.beta2, which
depends on
        activemodel (= 5.0.0.beta2)

    mongoid (~> 4.0.0) was resolved to 4.0.0, which depends on
      activemodel (~> 4.0)

    web-console (~> 3.0) was resolved to 3.1.1, which depends on
      activemodel (>= 4.2)

运行 bundle update 将从头开始重建您的快照,使用 只要 您的 Gemfile 中的 gem,这可能会解决冲突。

【问题讨论】:

  • 您确定错误来自捆绑提供的 Gemfile 吗?因为gem 'mongoid', '~&gt; 5.1.0'不应该导致mongoid (~&gt; 4.0.0) was resolved to 4.0.0, which depends on activemodel (~&gt; 4.0)
  • 这很简单:mongoid 还不能与 rails 5 一起使用。有一张公开的票,他们会在 mongoid 6 中添加它。jira.mongodb.org/browse/MONGOID-4218
  • 我创建了 rails new store --skip-active-record 就这个
  • @AZZ_B 你打算用mongoid吗?
  • 我在项目中使用过

标签: ruby-on-rails mongoid


【解决方案1】:

从几天前开始,您现在可以将其添加到您的 gemfile 中:

gem 'mongoid', git: 'https://github.com/mongodb/mongoid.git'

【讨论】:

  • 是的,这似乎有效。记得将 Rails 版本升级到 beta4(或阅读本文时您拥有的最新版本)
【解决方案2】:

我也遇到了同样的问题。我将 mongoid gem 版本更改为 6.1.0,运行 bundle update 后一切正常。

#mongoid gem
gem 'mongoid', '~> 6.1.0'

【讨论】:

    【解决方案3】:

    Mongoid on Rails 5 有一个功能分支。将其添加到您的 gemfile 中。

    gem 'mongoid', git: 'https://github.com/estolfo/mongoid.git', branch: 'MONGOID-4218-rails-5'
    

    【讨论】:

    • 看来这还不兼容 5.0.0.beta4 :(
    • @RomanGaufman 如果错误已报告给 Mongoid JIRA 跟踪器,兼容性应该很快。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-12
    • 1970-01-01
    • 2017-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多