简体   繁体   English

“哪个ruby”与rvm默认不同

[英]“which ruby” different from rvm default

I recently installed Ruby 2.1.1 with RVM, and I set that to the default. 我最近在Ruby 2.1.1上安装了RVM,并将其设置为默认值。 In my root directory it correctly sets current to ruby-2.1.1: 在我的根目录中,它正确地将当前设置为ruby-2.1.1:

$ rvm list

rvm rubies

   ruby-1.9.3-p448 [ x86_64 ]
   ruby-1.9.3-p545 [ x86_64 ]
=* ruby-2.1.1 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

$ which ruby
$ /Users/mynamehere/.rvm/rubies/ruby-2.1.1/bin/ruby

But when I move into my rails project, current is set back to 1.9.3, even though default is 2.1.1: 但是,当我进入Rails项目时,即使默认值为2.1.1,当前也会重新设置为1.9.3:

$ rvm list

rvm rubies

   ruby-1.9.3-p448 [ x86_64 ]
=> ruby-1.9.3-p545 [ x86_64 ]
 * ruby-2.1.1 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

$ which ruby
$ /Users/mynamehere/.rvm/rubies/ruby-1.9.3-p545/bin/ruby

Can someone tell me why the current ruby version changes depending on my directory, and how I can set 2.1.1 to be the default? 谁能告诉我为什么当前的ruby版本会根据我的目录而变化,以及如何将2.1.1设置为默认值? I've tried doing "$ rvm --default use 2.1.1" in my project directory, but that doesn't fix the issue. 我尝试在我的项目目录中执行“ $ rvm --default use 2.1.1”,但这不能解决问题。

Thanks! 谢谢!

You probably have a .ruby-version file in your Rails project folder which establishes the default for that project. 您的Rails项目文件夹中可能有一个.ruby-version文件,可为该项目建立默认文件。 Check for that and, if you have it, you can remove it or change it's contents to the version you want to use for that particular Rails project. 检查它,如果有,可以将其删除或将其内容更改为要用于该特定Rails项目的版本。

It's discussed (rather tersely) in the rvm website under Typical RVM Project Workflow . rvm网站(“ 典型RVM项目工作流程”下)中(而不是rvm地)进行了讨论。

You can also define your gemset specific to the project as well. 您还可以定义特定于项目的gemset。 It's a cool feature if you have multiple projects that require different versions. 如果您有多个需要不同版本的项目,这是一个很酷的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM