使用 rvm 创建 .ruby-version 和 .ruby-gemset

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21142065/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 23:14:17  来源:igfitidea点击:

Create .ruby-version and .ruby-gemset with rvm

ruby-on-railsrubyrvmgemset

提问by Tyler DeWitt

Is there a way to create the associated .ruby-versionand .ruby-gemsetfiles when creating a new gemset?

有没有一种方法来创建关联.ruby-version,并.ruby-gemset创建一个新的宝石时的文件吗?

With older versions of rvm, one could do rvm --create --rvmrc 1.8.7@project, but that creates .rvmrcfiles.

使用旧版本的 rvm,可以这样做rvm --create --rvmrc 1.8.7@project,但这会创建.rvmrc文件。

I thought I read somewhere we could use the --ruby-versioncommand line switch, but I have been unsuccessful in doing so.

我以为我在某个地方读到了我们可以使用--ruby-version命令行开关的内容,但是我这样做没有成功。

回答by cappie013

I recently had the same problem. rvm --helpled me to:

我最近遇到了同样的问题。rvm --help引导我:

rvm --create --ruby-version ruby-1.9.3@my-gemset  

It created both .ruby-gemsetand .ruby-version.

它创建了.ruby-gemset.ruby-version

回答by Bob Roberts

According to the official RVM docsyou can use this:

根据官方 RVM 文档,您可以使用:

echo 1.9.3 > .ruby-version

Or you can use this:

或者你可以使用这个:

rvm --ruby-version use 1.9.3@my_app

The second form will create both .ruby-versionand .ruby-gemset.

第二种形式将同时创建.ruby-version.ruby-gemset

回答by Jaskirat Singh

Suppose I am creating gemset for my rails app whose name is tptappthen we can do it in following way.

假设我正在为名为tptapp 的rails 应用程序创建 gemset,那么我们可以通过以下方式进行操作。

rvm use 2.2.2@tptapp --create

rvm 使用 2.2.2@tptapp --create

here tptappis name of gemset, 2.2.2 is Ruby version.

这里tptapp是 gemset 的名称,2.2.2 是 Ruby 版本。

回答by tobybot11

All of the above examples require you to type in your ruby version and gemset name .. which is close to the same keystrokes required to vi .ruby-gemset and vi .ruby-version. Assuming you are in a directory where you've already chosen your ruby version and you are pointing at the desired gemset.. this does the trick.

以上所有示例都要求您输入您的 ruby​​ 版本和 gemset 名称 .. 这与 vi .ruby-gemset 和 vi .ruby-version 所需的击键接近相同。假设您在一个目录中,您已经选择了您的 ruby​​ 版本并且您指向所需的 gemset.. 这就是诀窍。

bash# rvm --ruby-version use $(rvm-prompt)