【问题标题】:After Chage Rails version conflict occured .Bundler could not find compatible versions for gem发生更改 Rails 版本冲突后。Bundler 找不到 gem 的兼容版本
【发布时间】:2019-01-07 06:05:23
【问题描述】:

在我的新项目(ruby-2.5) 中,我不小心安装了rails 版本(5.2.2)。我应该安装rails(5.1.0)。所以我尝试降级版本并将gem文件更改为5.1.0。在bundle install 发生冲突之后。如何安全地切换到 rails 5.1.0 版本。

我做了什么:

  1. bundle exec gem 卸载 rails -v 5.2.2

  2. 将 gem 文件更改为 gem 'rails', '5.1.0'

  3. 捆绑安装

  4. 发生冲突。

作为,

Bundler could not find compatible versions for gem "activesupport":
In snapshot (Gemfile.lock):
activesupport (= 5.2.2)

In Gemfile:
sass-rails (~> 5.0) was resolved to 5.0.7, which depends on
sprockets-rails (< 4.0, >= 2.0) was resolved to 3.2.1, which depends 
on
actionpack (>= 4.0) was resolved to 5.2.2, which depends on
      activesupport (= 5.2.2)

rails (= 5.1.0) was resolved to 5.1.0, which depends on
activesupport (= 5.1.0)

Running `bundle update` will rebuild your snapshot from scratch, 
using only
the gems in your Gemfile, which may resolve the conflict.
  1. 关注消息和捆绑更新。但仍然出现错误。

宝石文件

    gem 'rails', '5.1.0'

    gem 'mysql2', '>= 0.4.4', '< 0.6.0'

    gem 'puma', '~> 3.11'

    gem 'sass-rails', '~> 5.0'

    gem 'uglifier', '>= 1.3.0'

    gem 'coffee-rails', '~> 4.2'

    gem 'jbuilder', '~> 2.5'

    gem 'bootsnap', '>= 1.1.0', require: false

    group :development, :test do

      gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]

    end

    group :development do

      gem 'web-console', '>= 3.3.0'

      gem 'listen', '>= 3.0.5', '< 3.2'

      gem 'spring'

      gem 'spring-watcher-listen', '~> 2.0.0'

    end

【问题讨论】:

  • 删除 Gemfile.lock 并重新运行 bundle install
  • 感谢您的回复。我做了“rm Gemfile.lock”,然后是“捆绑安装”,但还是一样。 Bundler 找不到 gem "bundler" 的兼容版本:在 Gemfile 中:rails (= 5.1.0) 被解析为 5.1.0,这取决于 bundler (= 1.3.0) 当前 Bundler 版本:bundler (2.0 .1) 这个 Gemfile 需要不同版本的 Bundler。也许您需要通过运行gem install bundler 来更新 Bundler?在任何来源中都找不到 gem 'bundler (= 1.3.0)',这是 gem 'rails (= 5.1.0)' 所需的。

标签: ruby-on-rails


【解决方案1】:

由于几天前刚刚发布的 Bundler 2.0 (https://bundler.io/blog/2019/01/04/an-update-on-the-bundler-2-release.html),您似乎还有一个问题。

# Make sure Gemfile.lock is removed
$ rm Gemfile.lock

# Remove Bundler v 2.0
$ gem uninstall bundler

# Install pre-2.0 Bundler 
$ gem install bundler -v '1.17.3'

# Finally, you should be able to
$ bundle

【讨论】:

  • 感谢您的回复!有效。但是,我现在有另一个与此相关的问题。我想我不应该问这个地方的新问题。无论如何感谢您的帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-31
  • 1970-01-01
  • 2022-08-14
  • 1970-01-01
  • 2017-07-17
  • 2018-02-09
相关资源
最近更新 更多