[英]Use rvmrc or ruby-version file to set a project gemset with RVM?
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
文件自动选择一个Ruby版本和宝石每当我cd
到项目目录。
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 to [.]ruby-version
切换到.ruby-version
rvm rvmrc to [.]ruby-version
或者用rvm rvmrc warning ignore /Users/userName/code/railsapps/rails-prelaunch-signup/.rvmrc
忽略这个警告rvm rvmrc warning ignore /Users/userName/code/railsapps/rails-prelaunch-signup/.rvmrc
,.rvmrc
将继续在RVM 1和2 RVM默认的项目文件,所有文件运行忽略警告rvm rvmrc warning ignore all.rvmrcs
。
Should I continue using my .rvmrc
file or should I switch to a .ruby-version
file? 我应该继续使用我的
.rvmrc
文件还是应该切换到.ruby-version
文件? Which is optimal? 哪个是最佳的? What are the ramifications?
有什么后果?
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 . 如果你唯一的目标是切换Ruby版本,那么使用
.ruby-version
,这是由其他Ruby版本切换器支持的,例如rbenv或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版本的名称,不会以任何方式执行。
If you use .ruby-version
you can include @gemset
in the file but this will not be compatible with other switchers. 如果您使用
.ruby-version
,则可以在文件中包含@gemset
,但这与其他切换器不兼容。 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-version
一起使用) 。
For example, if you have a simple .rvmrc
: 例如,如果你有一个简单的
.rvmrc
:
rvm use 1.9.3@my-app
It can be transformed to .ruby-version
: 它可以转换为
.ruby-version
:
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
从.rvmrc切换到.ruby-version + .ruby-gemset的快速简便方法
rvm rvmrc to .ruby-version
If you want create the .ruby-version
and .ruby-gemset
file in a short way you can use the commands like this: 如果要以简短的方式创建
.ruby-version
和.ruby-gemset
文件,可以使用如下命令:
rvm use 2.1.1@nancy --create
rvm --create --ruby-version 2.1.1@nancy
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). 转到项目的根目录,创建一个.rvmrc文件(
touch .rvmrc
),然后编辑rvm use 2.0.0-p451@your_gemset
(你的ruby版本和gemset名称)。 After save this file, you can type this command: 保存此文件后,您可以键入以下命令:
cd ../your_project
(you're in your_project directory), and the script in .rvmrc will execute. cd ../your_project
../ your_project (你在your_project目录中),.rvmrc中的脚本将会执行。
The RVM recommend to use ruby-version. RVM建议使用ruby-version。 You can run this command to switch from .rvmrc to .ruby-version
您可以运行此命令从.rvmrc切换到.ruby-version
rvm rvmrc to .ruby-version
What it does is create 2 files name .ruby-version , and .ruby-gemset and add this line 它的作用是创建2个文件名.ruby-version和.ruby-gemset并添加此行
ruby-2.0.0-p451
in .ruby-version .ruby-version中的
ruby-2.0.0-p451
your_gemset
in .ruby-gemset your_gemset
在.ruby,宝石
You can try to do it manually if you want :) 如果你想要,你可以尝试手动:)
Install rvm using: 使用以下命令安装rvm:
\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. 切换到特定的ruby版本。 For example, 1.8.7:
例如,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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.