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

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

问题描述

我已经使用 hombrew

酿制红宝石

brew install ruby

但是仍然使用默认1.8.7.如何切换osx以使用1.9.3作为默认红宝石?

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

这对于自制软件来说通常很重要,否则将使用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,您将看到所有已安装的红宝石以及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


UPDATE: I now don't think you should change /etc/paths

相反,您需要检查正在外壳中装载了.profile.bashrc.bash_login中的哪个,只需将/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天全站免登陆