OSX不使用最新的Ruby版本 [英] OSX not using latest Ruby version

查看:73
本文介绍了OSX不使用最新的Ruby版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在终端中运行ruby命令时,出现错误:

When I try to run a ruby command in terminal I get an error:

Ruby >= 2.1.9 required to run app (You have 2.0.0)

当我尝试

brew upgrade ruby

我知道

Error: ruby 2.3.1 already installed

以前,我尝试使用rvm安装ruby

Previously I tried installing ruby with rvm

curl -sSL https://get.rvm.io | bash -s stable --ruby

也许我有两个不同版本的Ruby运行?

Maybe I have two different versions of ruby running?

如何使我的系统使用最新版本的ruby?

How can I get my system to use the latest version of ruby?

肯定安装了两个版本

/usr/local/bin/ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin14]
ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

我的$ PATH似乎正确吗?

My $PATH seems correct?

-bash: /usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin: No such file or directory

EDIT2指定正确版本的ruby的完整路径:

EDIT2 specifying the full path to the correct version of ruby:

/usr/local/bin/ruby app.rb
/usr/local/bin/ruby: No such file or directory -- app (LoadError)

推荐答案

在最简单的情况下,您只需为安装了Homebrew的Ruby指定完全合格的PATH.例如:

In the simplest cases, you can just specify the fully-qualified PATH to your Homebrew-installed Ruby. For example:

/usr/local/bin/ruby /path/to/foo.rb

但是,如果需要gem或库,则需要使用诸如chruby,rvm或rbenv之类的Ruby版本管理器来增强您的游戏.您应该从不替换系统ruby,并管理所有没有版本管理器的Ruby所需要的环境变量,gem等,都超出了合理的堆栈溢出问题的范围.

However, if you need to require gems or libraries, you need to step up your game with a Ruby version manager such as chruby, rvm, or rbenv. You should never replace the system ruby, and managing all the environments variables, gems, and so forth that Ruby needs without a version manager is outside the scope of a reasonable Stack Overflow question.

这篇关于OSX不使用最新的Ruby版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆