如何切换到使用 Homebrew 安装的 ruby​​ 1.9.3? [英] How can I switch to ruby 1.9.3 installed using Homebrew?

查看:31
本文介绍了如何切换到使用 Homebrew 安装的 ruby​​ 1.9.3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 hombrew

brew 安装 ruby​​

brew install ruby

但是仍然使用默认的 1.8.7.如何切换 osx 以使用 1.9.3 作为默认 ruby​​?

But default 1.8.7 is still used. How can I switch osx to use 1.9.3 as default ruby?

推荐答案

建议你看看rvm.然后您可以使用 rvm use 1.9.3 --default

I suggest you take a look at rvm. You can then set it as default with rvm use 1.9.3 --default

但是如果您对自制软件的安装感到满意.

But if you are happy with your homebrew install.

然后只需更改PATH

这是我的/etc/paths

Here is my /etc/paths

# homebrews should always take precedence
/usr/local/bin

# the default stack
/usr/bin
/bin
/usr/sbin
/sbin

这通常对于 homebrew 很重要,否则将使用系统版本的 git、ruby、pg_admin... 代替 brew 版本.

This is important generally for homebrew, else the system version of git, ruby, pg_admin,... will all be used instead of the brew version.

如果你说which -a ruby​​,你会看到所有安装的ruby,以及PATH

if you say which -a ruby you'll see all the installed rubies, and the precedence in the PATH

例如

$ which -a ruby
/Users/matthew/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
/Users/matthew/.rvm/bin/ruby
/usr/bin/ruby

<小时>更新:我现在认为你不应该改变 /etc/paths

相反,您需要检查哪个 .profile.bashrc.bash_login 正在加载到您的 shell 中,然后添加/usr/local/bin 到您的路径.

Instead you need to check which of .profile, .bashrc, or .bash_login is being loaded in your shell, and just add /usr/local/bin to your path.

对我来说,我只有一个 .profile.如果您的主目录中不存在这些文件,您可以创建该文件.

For me, I only have a .profile. You can create that file if none of those files already exist in your home directory.

# homebrews should always take precedence
export PATH=/usr/local/bin:$PATH

这篇关于如何切换到使用 Homebrew 安装的 ruby​​ 1.9.3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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