捆绑包更新无法正常工作

bundle update not working correctly

这是我在更新包时遇到的错误:

Bundler 找不到 gem "railties" 的兼容版本: 在宝石文件中: coffee-rails (~> 4.1.0) 被解析为 4.1.0,这取决于 railties (< 5.0, >= 4.0.0)

rails (~> 5.2) was resolved to 5.2.0, which depends on
  railties (= 5.2.0)

sass-rails (~> 5.0) was resolved to 5.0.7, which depends on
  railties (< 6, >= 4.0.0)

web-console (~> 2.0) was resolved to 2.3.0, which depends on
  railties (>= 4.0)

我试图检查我的 rails -v,它告诉我 运行 捆绑更新,当我这样做时,我收到了这个错误。谁能帮忙?我迷路了

发生此错误是因为 Bundler 试图满足依赖项的版本要求,但由于 rails 5.2.0 需要版本 [=13] 中的 gem railties 而无法满足=],而 coffee-rails 4.1.0 需要小于 5.0 但大于或等于 4.0.0railties 版本。这两个要求相互冲突。

幸运的是,解决这个问题真的很简单:您需要做的就是将 coffee-rails gem 的版本要求提高到 ~> 4.2。这可以通过将 Gemfile 中的 gem "coffee-rails", "~> 4.1.0" 行(或类似行)更改为以下内容来完成:

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

更改后,bundle update 应该可以正常工作。