如何使用rvm升级ruby on rails应用程序的ruby版本 [英] How to upgrade ruby version of ruby on rails app using rvm

查看:44
本文介绍了如何使用rvm升级ruby on rails应用程序的ruby版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 rvm 安全地升级我的 ruby​​ on rails 应用程序以使用新的 ruby​​ 版本?

How do I safely upgrade my ruby on rails app to use a new ruby version, using rvm?

推荐答案

假设你的应用是 my_app 并且你使用的是 ruby​​ 版本 a.b.c 并且想要转到 ruby​​ 版本 x.y.z.

Suppose your app is my_app and you are using ruby version a.b.c and want to go to ruby version x.y.z.

步骤 0

在开始之前,请确保您拥有最新版本的 rvm

Before starting, make sure you have the up to date version of rvm

rvm get stable
rvm reload

第一步

首先,如果您当前的 ruby​​ 版本没有 gemset,请创建一个并将其设为默认值.如果您的升级破坏了您的测试,这为您提供了一种简单的返回方法.如果您不想这样做,请转到第 2 步.

First if you do not have a gemset for your current ruby version create one and make it the default. This gives you an easy way to go back if your upgrade breaks your tests. If you do not want to do this, go to step 2.

rvm gemset create my_app_abc

切换到该 gemset 并将 gems 安装到该 gemset 中,并使其成为目录的默认 gemset

The switch to that gemset and install the gems into that gemset, and make it the default gemset for the directory

rvm a.b.c@my_app_abc
bundle
rvm --ruby-version use a.b.c@my_app_abc

第 2 步

现在升级到新的 ruby​​ 版本并为其创建一个 gemset.

Now upgrade to the new ruby version and create a gemset for it.

rvm install x.y.z
rvm use x.y.z
rvm gemset create my_app_xyz
rvm x.y.z@my_app_xyz

在您的 Gemfile 中指定 ruby​​ 版本被认为是最佳实践,因此确保你的 Gemfile 顶部有 ruby 'x.y.z' .那么

It is considered best practice to specify the ruby version in your Gemfile so make sure you have ruby 'x.y.z' at the top of your Gemfile. Then

gem install bundle
bundle

这就是乐趣开始的地方,此时您可能会遇到错误,并结合使用按照错误说明或谷歌搜索寻求帮助等方法来解决这些问题.当您可以成功捆绑时,然后运行所有测试.

This is where the fun can start, you may get errors at this point and use a combination of following the error instructions or googling for help, etc to solve them. When you can bundle successfully, then run all your tests.

当您的测试全部通过后,您就已成功升级.如果卡住了,可以使用 rvm a.b.c@my_app_abc 返回到旧安装.

When your tests have all passed, then you have successfuly upgraded. If you get stuck, you can go back to your old installation, using rvm a.b.c@my_app_abc.

一旦您对新安装感到满意,请执行

Once you are happy with your new installation then do

rvm --ruby-version use x.y.z@my_app_xyz

使其成为此应用程序的默认设置.这意味着当你从其他项目切换到这个应用程序时,它会自动加载 ruby​​ 版本 x.y.z 和相应的 gemset.

to make this the default setup for this app. This means when you change into this app from other projects, it will automatically load ruby version x.y.z and the corresponding gemset.

这篇关于如何使用rvm升级ruby on rails应用程序的ruby版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆