如何在Mac Leopard中安装Ruby ?

时间:2022-11-04 07:16:07

Can anyone please give directions on how to install ruby 1.9 I tried installation directions given all over the web. Can't get it to work. Please kindly give step by step direction. I tried using macports but everytime I type in ruby -v it gives me 1.8.6.

有谁能告诉我如何安装ruby 1.9我试过了安装指南,在网上都有。不能让它工作。请一步步指导。我尝试使用macports,但是每次我输入ruby -v,它都会给我1.8.6。

9 个解决方案

#1


19  

rvm is easiest way to manage your ruby installation on OSX.

rvm是在OSX上管理ruby安装的最简单方法。

If you are using rvm, you will able to install 1.9.1, 1.9.2, jruby, ree by typing rvm install 1.9.1

如果您正在使用rvm,您将能够通过输入rvm install 1.9.1来安装1.9.1、1.9.2、jruby、ree

type rvm default to reset your ruby version back to 1.8.6

键入rvm默认值,将ruby版本重置为1.8.6

How to install rvm

如何安装区

sudo gem install rvm -s http://gemcutter.org/

rvm-install

rvm install 1.9.1

rvm use 1.9.1

ruby -v  # show ruby 1.9.1 version

rvm default

ruby -v  # show ruby 1.8.6 version

cheers

干杯

#2


13  

Install Homebrew.

安装自酿酒。

brew install ruby installs the current stable version of ruby.

brew install ruby安装了当前稳定版的ruby。

#3


7  

Use Ruby Version Manager. It will allow you to install most versions of Ruby and help you manage gems across them.

使用Ruby版本经理。它将允许您安装大多数Ruby版本,并帮助您管理它们之间的gem。

#4


4  

Ok this is how I remember doing it

我记得就是这样做的

  1. Install Macports
  2. 安装Macports
  3. Type sudo port install ruby19
  4. 类型sudo端口安装ruby19
  5. Make sure that /opt/local/bin is in your path. If not add it.
  6. 确保/opt/local/bin在您的路径中。如果没有添加它。
  7. Now to use ruby1.9 you type ruby1.9 example.rb
  8. 现在要使用ruby1.9,输入ruby1.9 example.rb

Also additionally if you dont want to use ruby command to use the default version. You can create a simple symlink in which make the ruby at /usr/bin/ruby point to /opt/local/bin/ruby1.9.

另外,如果您不想使用ruby命令来使用默认版本的话。您可以创建一个简单的符号链接,使ruby at /usr/bin/ruby指向/opt/local/bin/ruby1.9。

That way your ruby version will be 1.9. However I dont recommend doing that. As there are certain gems, that might not work with 1.9, which might be affected

这样你的ruby版本就会是1.9。但是我不建议这样做。由于有某些宝石,可能无法使用1.9,因此可能会受到影响

#5


3  

Not sure if you ever solved this. But it sounds like 1 of 2 problems:

不确定你是否解决过这个问题。但这听起来像是两个问题中的一个:

1. You installed the wrong ruby with MacPorts

1。您在MacPorts中安装了错误的ruby

if you just ran port install ruby, then you installed the old version, which explains why ruby -v still shows 1.8.6.

如果您只是运行端口安装ruby,那么您就安装了旧版本,这解释了为什么ruby -v仍然显示1.8.6。

If you ran port install ruby19, then you installed ruby 1.9, but under the name ruby19. To access it, you'd have to type ruby19 in place of ruby...so ruby19 script/generate, ruby19 -v...etc.

如果您运行了端口install ruby19,那么您安装了ruby 1.9,但是名称为ruby19。要访问它,您必须输入ruby19来代替ruby……ruby19脚本/generate, ruby19 -v等等。

To fix that you can do port install ruby19+nosuffix

要解决这个问题,可以进行端口安装ruby19+nosuffix

2. you still have your PATH set to the old Ruby, which is why you're getting 1.8.6 on ruby -v.

2。您仍然有您的路径设置到旧Ruby,这就是为什么您在Ruby -v上得到1.8.6的原因。

First you gotta figure out where OSX is looking for your ruby by typing which ruby. If you're using MacPorts, that command should return /opt/local/bin/ruby. If which ruby returns /usr/bin/ruby, then it's still finding the default ruby that comes with OSX, which is 1.8.6.

首先,您需要通过键入哪个ruby来确定OSX正在寻找您的ruby。如果您使用的是MacPorts,那么该命令应该返回/opt/local/bin/ruby。如果哪个ruby返回/usr/bin/ruby,那么它仍然在寻找OSX附带的默认ruby,即1.8.6。

To change your PATH, go open up .bash_profile, located in your user folder (if you have textmate, you can do mate ~/.bash_profile). Add in this line and save:

要更改路径,请打开.bash_profile,位于用户文件夹中(如果您有textmate,您可以进行mate ~/.bash_profile)。加入本行并保存:

echo PATH="/opt/local/bin:/opt/bin:$PATH"

Basically you add the MacPorts ruby into your PATH, so the system looks for ruby in the /opt folder too. Also, maybe more importantly, you put the MacPorts path in front of the default PATH, so it will find that one first.

基本上,您将MacPorts ruby添加到路径中,因此系统也会在/opt文件夹中查找ruby。同样,也许更重要的是,你把MacPorts路径放在默认路径的前面,这样它会先找到这个路径。

Goodluck with that. Personally though, I vote for Homebrew. You can find my setup for that at my blog.

古德勒克。就我个人而言,我倾向于自制啤酒。你可以在我的博客上找到我的设置。

#6


2  

On my MacBook Pro I just did a good old compile and install. Download the 1.9.1 source from the Ruby web site (www.ruby-lang.org) and then compile. It'll install to /usr/local/bin so you will not corrupt the 1.8 if you wanted to revert back.

在我的MacBook Pro上,我只是做了一个很好的旧编译和安装。从Ruby网站(www.ruby-lang.org)下载1.9.1源代码,然后进行编译。它将安装到/usr/local/bin,这样您就不会损坏1.8如果您想要回退。

I never used the ports myself, but I know a lot that have/do. http://hivelogic.com/articles/ruby-rails-leopard is a good online guide for people not familiar with compiling and installing from source code.

我自己从来没有用过港口,但我知道很多港口有。http://hivelogic.com/articles/ruby-rails-leopard对于不熟悉源代码编译和安装的人来说是一个很好的在线指南。

#7


1  

Just had to do this on a factory-fresh Mac last night, and it's gotten slightly more complicated recently. GCC is no longer directly supported by Apple, as they prefer Clang, and Xcode 4.3+ requires the command line tools to be installed separately before you can access Clang from the terminal. So here goes!

昨晚我不得不在一个工厂新鲜的Mac上做这个,最近它变得有点复杂了。GCC不再直接支持Apple,因为他们更喜欢Clang, Xcode 4.3+要求在从终端访问Clang之前分别安装命令行工具。就这样了!

1.) Install XCode.(it's free!)

1)。安装XCode。(它是免费的!)

2.) Install RVM. Go to a terminal window and enter:

2)。安装区。进入终端窗口,输入:

bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

3a.) If you've installed XCode before 4.3, skip this step. Go to Xcode>Preferences>Downloads tab and install the XCode command Line Tools. This will let you access clang from Terminal.

3)。如果您在4.3之前安装了XCode,那么跳过这个步骤。转到Xcode>Preferences>下载选项卡并安装Xcode命令行工具。这将允许您从终端访问clang。

3.)Open up terminal and enter:

3)。打开终端进入:

rvm install 1.9.3 --with-gcc=clang

this will install ruby 1.9.3 in OSX

这将在OSX中安装ruby 1.9.3

#8


0  

You can use the one-click-installer :

你可以使用一键安装:

http://rubyosx.rubyforge.org/

http://rubyosx.rubyforge.org/

#9


-1  

  1. Install MacPorts
  2. 安装MacPorts
  3. Type port install ruby19
  4. 输入端口安装ruby19

#1


19  

rvm is easiest way to manage your ruby installation on OSX.

rvm是在OSX上管理ruby安装的最简单方法。

If you are using rvm, you will able to install 1.9.1, 1.9.2, jruby, ree by typing rvm install 1.9.1

如果您正在使用rvm,您将能够通过输入rvm install 1.9.1来安装1.9.1、1.9.2、jruby、ree

type rvm default to reset your ruby version back to 1.8.6

键入rvm默认值,将ruby版本重置为1.8.6

How to install rvm

如何安装区

sudo gem install rvm -s http://gemcutter.org/

rvm-install

rvm install 1.9.1

rvm use 1.9.1

ruby -v  # show ruby 1.9.1 version

rvm default

ruby -v  # show ruby 1.8.6 version

cheers

干杯

#2


13  

Install Homebrew.

安装自酿酒。

brew install ruby installs the current stable version of ruby.

brew install ruby安装了当前稳定版的ruby。

#3


7  

Use Ruby Version Manager. It will allow you to install most versions of Ruby and help you manage gems across them.

使用Ruby版本经理。它将允许您安装大多数Ruby版本,并帮助您管理它们之间的gem。

#4


4  

Ok this is how I remember doing it

我记得就是这样做的

  1. Install Macports
  2. 安装Macports
  3. Type sudo port install ruby19
  4. 类型sudo端口安装ruby19
  5. Make sure that /opt/local/bin is in your path. If not add it.
  6. 确保/opt/local/bin在您的路径中。如果没有添加它。
  7. Now to use ruby1.9 you type ruby1.9 example.rb
  8. 现在要使用ruby1.9,输入ruby1.9 example.rb

Also additionally if you dont want to use ruby command to use the default version. You can create a simple symlink in which make the ruby at /usr/bin/ruby point to /opt/local/bin/ruby1.9.

另外,如果您不想使用ruby命令来使用默认版本的话。您可以创建一个简单的符号链接,使ruby at /usr/bin/ruby指向/opt/local/bin/ruby1.9。

That way your ruby version will be 1.9. However I dont recommend doing that. As there are certain gems, that might not work with 1.9, which might be affected

这样你的ruby版本就会是1.9。但是我不建议这样做。由于有某些宝石,可能无法使用1.9,因此可能会受到影响

#5


3  

Not sure if you ever solved this. But it sounds like 1 of 2 problems:

不确定你是否解决过这个问题。但这听起来像是两个问题中的一个:

1. You installed the wrong ruby with MacPorts

1。您在MacPorts中安装了错误的ruby

if you just ran port install ruby, then you installed the old version, which explains why ruby -v still shows 1.8.6.

如果您只是运行端口安装ruby,那么您就安装了旧版本,这解释了为什么ruby -v仍然显示1.8.6。

If you ran port install ruby19, then you installed ruby 1.9, but under the name ruby19. To access it, you'd have to type ruby19 in place of ruby...so ruby19 script/generate, ruby19 -v...etc.

如果您运行了端口install ruby19,那么您安装了ruby 1.9,但是名称为ruby19。要访问它,您必须输入ruby19来代替ruby……ruby19脚本/generate, ruby19 -v等等。

To fix that you can do port install ruby19+nosuffix

要解决这个问题,可以进行端口安装ruby19+nosuffix

2. you still have your PATH set to the old Ruby, which is why you're getting 1.8.6 on ruby -v.

2。您仍然有您的路径设置到旧Ruby,这就是为什么您在Ruby -v上得到1.8.6的原因。

First you gotta figure out where OSX is looking for your ruby by typing which ruby. If you're using MacPorts, that command should return /opt/local/bin/ruby. If which ruby returns /usr/bin/ruby, then it's still finding the default ruby that comes with OSX, which is 1.8.6.

首先,您需要通过键入哪个ruby来确定OSX正在寻找您的ruby。如果您使用的是MacPorts,那么该命令应该返回/opt/local/bin/ruby。如果哪个ruby返回/usr/bin/ruby,那么它仍然在寻找OSX附带的默认ruby,即1.8.6。

To change your PATH, go open up .bash_profile, located in your user folder (if you have textmate, you can do mate ~/.bash_profile). Add in this line and save:

要更改路径,请打开.bash_profile,位于用户文件夹中(如果您有textmate,您可以进行mate ~/.bash_profile)。加入本行并保存:

echo PATH="/opt/local/bin:/opt/bin:$PATH"

Basically you add the MacPorts ruby into your PATH, so the system looks for ruby in the /opt folder too. Also, maybe more importantly, you put the MacPorts path in front of the default PATH, so it will find that one first.

基本上,您将MacPorts ruby添加到路径中,因此系统也会在/opt文件夹中查找ruby。同样,也许更重要的是,你把MacPorts路径放在默认路径的前面,这样它会先找到这个路径。

Goodluck with that. Personally though, I vote for Homebrew. You can find my setup for that at my blog.

古德勒克。就我个人而言,我倾向于自制啤酒。你可以在我的博客上找到我的设置。

#6


2  

On my MacBook Pro I just did a good old compile and install. Download the 1.9.1 source from the Ruby web site (www.ruby-lang.org) and then compile. It'll install to /usr/local/bin so you will not corrupt the 1.8 if you wanted to revert back.

在我的MacBook Pro上,我只是做了一个很好的旧编译和安装。从Ruby网站(www.ruby-lang.org)下载1.9.1源代码,然后进行编译。它将安装到/usr/local/bin,这样您就不会损坏1.8如果您想要回退。

I never used the ports myself, but I know a lot that have/do. http://hivelogic.com/articles/ruby-rails-leopard is a good online guide for people not familiar with compiling and installing from source code.

我自己从来没有用过港口,但我知道很多港口有。http://hivelogic.com/articles/ruby-rails-leopard对于不熟悉源代码编译和安装的人来说是一个很好的在线指南。

#7


1  

Just had to do this on a factory-fresh Mac last night, and it's gotten slightly more complicated recently. GCC is no longer directly supported by Apple, as they prefer Clang, and Xcode 4.3+ requires the command line tools to be installed separately before you can access Clang from the terminal. So here goes!

昨晚我不得不在一个工厂新鲜的Mac上做这个,最近它变得有点复杂了。GCC不再直接支持Apple,因为他们更喜欢Clang, Xcode 4.3+要求在从终端访问Clang之前分别安装命令行工具。就这样了!

1.) Install XCode.(it's free!)

1)。安装XCode。(它是免费的!)

2.) Install RVM. Go to a terminal window and enter:

2)。安装区。进入终端窗口,输入:

bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

3a.) If you've installed XCode before 4.3, skip this step. Go to Xcode>Preferences>Downloads tab and install the XCode command Line Tools. This will let you access clang from Terminal.

3)。如果您在4.3之前安装了XCode,那么跳过这个步骤。转到Xcode>Preferences>下载选项卡并安装Xcode命令行工具。这将允许您从终端访问clang。

3.)Open up terminal and enter:

3)。打开终端进入:

rvm install 1.9.3 --with-gcc=clang

this will install ruby 1.9.3 in OSX

这将在OSX中安装ruby 1.9.3

#8


0  

You can use the one-click-installer :

你可以使用一键安装:

http://rubyosx.rubyforge.org/

http://rubyosx.rubyforge.org/

#9


-1  

  1. Install MacPorts
  2. 安装MacPorts
  3. Type port install ruby19
  4. 输入端口安装ruby19