为什么我的Ruby版本有冲突? [英] Why are my Ruby versions conflicting?
问题描述
当我在~home
文件夹中运行ruby -v
时,我得到:
When I run ruby -v
in my ~home
folder, I get:
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.3.0]
但是现在我正在尝试运行一个应用程序,并且缺少一些宝石.搜索它们,我被告知要使用Ruby 1.9运行此应用程序,但是在/app文件夹中,当我运行ruby -v
时,我得到:
But now I am trying to run an app, and there are some missing gems. Searching for them, I am told to run this app using Ruby 1.9, but in the /app folder, when I run ruby -v
, I get:
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
为什么会这样,如何恢复我的2.0.当前版本的Ruby?
Why is it so and how can I recover my 2.0. current version of Ruby?
推荐答案
通常,您将使用某种Ruby版本管理工具,例如rvm
或rbenv
.
这些使每个项目都有一个独特的Ruby版本(AKA目录)以及单独的gem集.
Usually you would use some kind of Ruby version management tool like rvm
or rbenv
.
These make it possible to have a unique Ruby version for every project (AKA directory), as well as separate gem sets.
使用rvm
,您可以通过运行rvm use ruby-1.8.7
来切换当前的Ruby.
Using rvm
you can switch your current Ruby by running rvm use ruby-1.8.7
.
使用ls -a
检查项目目录中的文件,例如:
Check your project directory using ls -a
for files like:
- .rvmrc
- .ruby-version
通常在这里选择所需的Ruby版本,并在cd
进入项目目录后立即使用.
Normally the required Ruby version is selected here and used as soon as you cd
into the project directory.
这篇关于为什么我的Ruby版本有冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!