I use RVM, the Ruby Version Manager to specify a Ruby version and a set of gems for each of my Rails projects.
我使用RVM, Ruby版本管理器为我的每个Rails项目指定Ruby版本和一组gem。
I have a .rvmrc
file to automatically select a Ruby version and gemset whenever I cd
into a project directory.
我有一个.rvmrc文件,当我cd进入项目目录时,它会自动选择一个Ruby版本和gemset。
After installing RVM 1.19.0, I get a message
安装RVM 1.19.0之后,我得到一个消息。
You are using
.rvmrc
, it requires trusting, it is slower and it is not compatible with other ruby managers, you can switch to.ruby-version
usingrvm rvmrc to [.]ruby-version
or ignore this warnings withrvm rvmrc warning ignore /Users/userName/code/railsapps/rails-prelaunch-signup/.rvmrc
,.rvmrc
will continue to be the default project file in RVM 1 and RVM 2, to ignore the warning for all files runrvm rvmrc warning ignore all.rvmrcs
.您正在使用.rvmrc,它需要信任,它较慢,而且它与其他ruby管理器不兼容,您可以使用rvm rvmrc切换到.ruby版本。使用rvm rvmrc警告忽略/用户/用户名/代码/railsapps/rails-prelaunch-signup/。rvmrc将继续是RVM 1和RVM 2中的默认项目文件,忽略所有运行RVM rvmrc警告的所有文件的警告。
Should I continue using my .rvmrc
file or should I switch to a .ruby-version
file? Which is optimal? What are the ramifications?
我是否应该继续使用.rvmrc文件,还是应该切换到.ruby版本的文件?这是最佳的吗?后果是什么?
5 个解决方案
#1
362
If your .rvmrc
file contains custom shell code, continue using .rvmrc
as it allows you to include any shell code.
如果您的.rvmrc文件包含自定义的shell代码,请继续使用.rvmrc,因为它允许您包含任何shell代码。
If your only aim is to switch Ruby versions, then use .ruby-version
which is supported by other Ruby version switchers such as rbenv or chruby. This file also does not require trusting as it is just the name of a Ruby version and will not be executed in any way.
如果您的唯一目标是切换Ruby版本,那么就使用. Ruby版本,其他Ruby版本转换程序(如rbenv或chruby)支持它。该文件也不需要信任,因为它只是Ruby版本的名称,不会以任何方式执行。
If you use .ruby-version
you can include @gemset
in the file but this will not be compatible with other switchers. To maintain compatibility use the gemset name in a separate file .ruby-gemset
which is ignored by other tools (it works only together with .ruby-version
).
如果使用.ruby版本,可以在文件中包含@gemset,但这与其他切换器不兼容。为了保持兼容性,在一个单独的文件中使用gemset名称。ruby-gemset被其他工具忽略(它只与.ruby版本一起工作)。
For example, if you have a simple .rvmrc
:
例如,如果你有一个简单的。rvmrc:
rvm use 1.9.3@my-app
It can be transformed to .ruby-version
:
它可以转换为。ruby版本:
1.9.3
And .ruby-gemset
:
和.ruby-gemset:
my-app
Be sure to remove the .rvmrc
file as it takes precedence over any other project configuration files:
请务必删除.rvmrc文件,因为它优先于任何其他项目配置文件:
rm .rvmrc
#2
74
Quick and easy way to switch from .rvmrc to .ruby-version + .ruby-gemset
快速简单的方法从。rvmrc到。ruby版本+ .ruby-gemset。
rvm rvmrc to .ruby-version
#3
3
If you want create the .ruby-version
and .ruby-gemset
file in a short way you can use the commands like this:
如果您想在短时间内创建.ruby版本和.ruby-gemset文件,您可以使用以下命令:
rvm use 2.1.1@nancy --create
rvm --create --ruby-version 2.1.1@nancy
#4
2
You can try both. Go to the root of your project, create a .rvmrc file (touch .rvmrc
), then edit rvm use 2.0.0-p451@your_gemset
(your ruby version and gemset name). After save this file, you can type this command:
你可以试试。转到项目的根目录,创建一个.rvmrc文件(touch .rvmrc),然后编辑rvm使用2.0.0-p451@your_gemset(您的ruby版本和gemset名称)。保存此文件后,您可以键入以下命令:
cd ../your_project
(you're in your_project directory), and the script in .rvmrc will execute.
cd . ./your_project(您位于your_project目录中),并且.rvmrc中的脚本将执行。
The RVM recommend to use ruby-version. You can run this command to switch from .rvmrc to .ruby-version
RVM建议使用ruby版本。您可以运行此命令以从.rvmrc切换到.ruby版本。
rvm rvmrc to .ruby-version
rvm rvmrc,.ruby-version
What it does is create 2 files name .ruby-version, and .ruby-gemset and add this line
它所做的是创建两个文件的名称。ruby版本和.ruby-gemset并添加这一行!
ruby-2.0.0-p451
in .ruby-version
在.ruby-version ruby-2.0.0-p451
your_gemset
in .ruby-gemset
在.ruby-gemset your_gemset
You can try to do it manually if you want :)
如果你想,你可以尝试手动操作:)
#5
0
Install rvm using:
安装区使用:
\curl -sSL https://get.rvm.io | bash -s stable --rails
Install different ruby versions:
安装不同的ruby版本:
rvm install 1.8.7
rvm install 1.9.2
Switch to specific ruby version. For example, 1.8.7:
切换到特定的ruby版本。例如,1.8.7:
rvm use 1.8.7
To create a gemse:
创建一个gemse:
rvm gemset create project_gemset
And to use a gemset:
并使用gemset:
rvm gemset use project_gemset
#1
362
If your .rvmrc
file contains custom shell code, continue using .rvmrc
as it allows you to include any shell code.
如果您的.rvmrc文件包含自定义的shell代码,请继续使用.rvmrc,因为它允许您包含任何shell代码。
If your only aim is to switch Ruby versions, then use .ruby-version
which is supported by other Ruby version switchers such as rbenv or chruby. This file also does not require trusting as it is just the name of a Ruby version and will not be executed in any way.
如果您的唯一目标是切换Ruby版本,那么就使用. Ruby版本,其他Ruby版本转换程序(如rbenv或chruby)支持它。该文件也不需要信任,因为它只是Ruby版本的名称,不会以任何方式执行。
If you use .ruby-version
you can include @gemset
in the file but this will not be compatible with other switchers. To maintain compatibility use the gemset name in a separate file .ruby-gemset
which is ignored by other tools (it works only together with .ruby-version
).
如果使用.ruby版本,可以在文件中包含@gemset,但这与其他切换器不兼容。为了保持兼容性,在一个单独的文件中使用gemset名称。ruby-gemset被其他工具忽略(它只与.ruby版本一起工作)。
For example, if you have a simple .rvmrc
:
例如,如果你有一个简单的。rvmrc:
rvm use 1.9.3@my-app
It can be transformed to .ruby-version
:
它可以转换为。ruby版本:
1.9.3
And .ruby-gemset
:
和.ruby-gemset:
my-app
Be sure to remove the .rvmrc
file as it takes precedence over any other project configuration files:
请务必删除.rvmrc文件,因为它优先于任何其他项目配置文件:
rm .rvmrc
#2
74
Quick and easy way to switch from .rvmrc to .ruby-version + .ruby-gemset
快速简单的方法从。rvmrc到。ruby版本+ .ruby-gemset。
rvm rvmrc to .ruby-version
#3
3
If you want create the .ruby-version
and .ruby-gemset
file in a short way you can use the commands like this:
如果您想在短时间内创建.ruby版本和.ruby-gemset文件,您可以使用以下命令:
rvm use 2.1.1@nancy --create
rvm --create --ruby-version 2.1.1@nancy
#4
2
You can try both. Go to the root of your project, create a .rvmrc file (touch .rvmrc
), then edit rvm use 2.0.0-p451@your_gemset
(your ruby version and gemset name). After save this file, you can type this command:
你可以试试。转到项目的根目录,创建一个.rvmrc文件(touch .rvmrc),然后编辑rvm使用2.0.0-p451@your_gemset(您的ruby版本和gemset名称)。保存此文件后,您可以键入以下命令:
cd ../your_project
(you're in your_project directory), and the script in .rvmrc will execute.
cd . ./your_project(您位于your_project目录中),并且.rvmrc中的脚本将执行。
The RVM recommend to use ruby-version. You can run this command to switch from .rvmrc to .ruby-version
RVM建议使用ruby版本。您可以运行此命令以从.rvmrc切换到.ruby版本。
rvm rvmrc to .ruby-version
rvm rvmrc,.ruby-version
What it does is create 2 files name .ruby-version, and .ruby-gemset and add this line
它所做的是创建两个文件的名称。ruby版本和.ruby-gemset并添加这一行!
ruby-2.0.0-p451
in .ruby-version
在.ruby-version ruby-2.0.0-p451
your_gemset
in .ruby-gemset
在.ruby-gemset your_gemset
You can try to do it manually if you want :)
如果你想,你可以尝试手动操作:)
#5
0
Install rvm using:
安装区使用:
\curl -sSL https://get.rvm.io | bash -s stable --rails
Install different ruby versions:
安装不同的ruby版本:
rvm install 1.8.7
rvm install 1.9.2
Switch to specific ruby version. For example, 1.8.7:
切换到特定的ruby版本。例如,1.8.7:
rvm use 1.8.7
To create a gemse:
创建一个gemse:
rvm gemset create project_gemset
And to use a gemset:
并使用gemset:
rvm gemset use project_gemset