Gem 从 rails 4.2.10 升级到 rails 5.0.0 期间依赖项不兼容
Gem dependencies incompatibality during upgrade of rails 4.2.10 to rails 5.0.0
我正在升级我们的 rails 4 应用程序。
在 rails upgrade guide 之后,我在 gemfile
中更新了当前 rails 版本,将 4.2.10
替换为 5.0.0
。
但在 运行 bundle update rails
之后,即使在 运行 4.2.10
(使用 rails 4.2.10
)之后,我仍然遇到许多不兼容问题,这应该将所有宝石更新为最新版本。
以下是我在 运行 bundle update rails
与 gemfile 中的 rails 5.0.0
之后遇到的兼容性错误:
Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
active_link_to was resolved to 1.0.3, which depends on
actionpack
active_model_serializers was resolved to 0.10.2, which depends on
actionpack (< 6, >= 4.1)
inherited_resources was resolved to 1.6.0, which depends on
actionpack (< 5, >= 3.2)
inherited_resources was resolved to 1.6.0, which depends on
actionpack (< 5, >= 3.2)
kaminari was resolved to 0.17.0, which depends on
actionpack (>= 3.0.0)
rails (= 5.0.0) was resolved to 5.0.0, which depends on
actionpack (= 5.0.0)
rails (= 5.0.0) was resolved to 5.0.0, which depends on
actionpack (= 5.0.0)
rspec-rails (= 3.6.0) was resolved to 3.6.0, which depends on
actionpack (>= 3.0)
你的问题是什么?
在更新 gem 之前,您必须检查您的项目代码和依赖项是否已准备好进行此更改,如果这是一个大型应用程序,这不是一个简单的过程。
1。回到你拥有的 rails 版本。
gem install <gem> -v=<version>
例如
gem install rails -v=4.2
这样您的 rails 应用程序应该使用您想要的版本。
2。更新其余 gems...(如果您不确定新版本,不推荐它)
检查你的Gemfile.lock:
bundle update
或删除您的 Gemfile.lock(当您尝试启动 rails 应用程序时,它将自动重建)。
经过多次试验和测试,我终于能够 运行 捆绑安装。列出我尝试过的步骤-
1.使用 rails new
和 rails 5
.
创建一个新的演示 rails 应用程序
2。删除现有 Gemfile.lock
.
3。删除所有当前 gems: (我在 gem list --no-versions
中使用 for i; do gem uninstall -aIx $i; done 命令引用自 here。)
4.将现有 Gemfile
替换为通过创建新 rails 5
应用程序 生成的新应用程序。 (假设您将拥有现有 Gemfile
的备份副本。)
5.将单个 gem 从旧文件复制到新文件。
6. 运行bundle install
。 (你应该在这次执行后有一个 :)。)
7. 运行 rails app:update
继续升级过程。
我正在升级我们的 rails 4 应用程序。
在 rails upgrade guide 之后,我在 gemfile
中更新了当前 rails 版本,将 4.2.10
替换为 5.0.0
。
但在 运行 bundle update rails
之后,即使在 运行 4.2.10
(使用 rails 4.2.10
)之后,我仍然遇到许多不兼容问题,这应该将所有宝石更新为最新版本。
以下是我在 运行 bundle update rails
与 gemfile 中的 rails 5.0.0
之后遇到的兼容性错误:
Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
active_link_to was resolved to 1.0.3, which depends on
actionpack
active_model_serializers was resolved to 0.10.2, which depends on
actionpack (< 6, >= 4.1)
inherited_resources was resolved to 1.6.0, which depends on
actionpack (< 5, >= 3.2)
inherited_resources was resolved to 1.6.0, which depends on
actionpack (< 5, >= 3.2)
kaminari was resolved to 0.17.0, which depends on
actionpack (>= 3.0.0)
rails (= 5.0.0) was resolved to 5.0.0, which depends on
actionpack (= 5.0.0)
rails (= 5.0.0) was resolved to 5.0.0, which depends on
actionpack (= 5.0.0)
rspec-rails (= 3.6.0) was resolved to 3.6.0, which depends on
actionpack (>= 3.0)
你的问题是什么?
在更新 gem 之前,您必须检查您的项目代码和依赖项是否已准备好进行此更改,如果这是一个大型应用程序,这不是一个简单的过程。
1。回到你拥有的 rails 版本。
gem install <gem> -v=<version>
例如
gem install rails -v=4.2
这样您的 rails 应用程序应该使用您想要的版本。
2。更新其余 gems...(如果您不确定新版本,不推荐它)
检查你的Gemfile.lock:
bundle update
或删除您的 Gemfile.lock(当您尝试启动 rails 应用程序时,它将自动重建)。
经过多次试验和测试,我终于能够 运行 捆绑安装。列出我尝试过的步骤-
1.使用 rails new
和 rails 5
.
2。删除现有 Gemfile.lock
.
3。删除所有当前 gems: (我在 gem list --no-versions
中使用 for i; do gem uninstall -aIx $i; done 命令引用自 here。)
4.将现有 Gemfile
替换为通过创建新 rails 5
应用程序 生成的新应用程序。 (假设您将拥有现有 Gemfile
的备份副本。)
5.将单个 gem 从旧文件复制到新文件。
6. 运行bundle install
。 (你应该在这次执行后有一个 :)。)
7. 运行 rails app:update
继续升级过程。