macos 如何在 Mac 上将系统 Ruby 更新到 1.9.2?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6003620/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:03:28  来源:igfitidea点击:

How to update system Ruby to 1.9.2 on Mac?

rubymacossystemrvm

提问by user292071

I saw an answer saying I should use RVM. But I don't know how even after:

我看到一个回答说我应该使用 RVM。但我不知道之后如何:

$ rvm system
$ rvm current
system

$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

回答by the Tin Man

The title of the question, "How to update system Ruby to 1.9.2 on Mac" makes me wonder if you are trying to upgrade Apple's installation of Ruby 1.8.7 to 1.9.2. If that is true, STOP and do NOT try that. The Ruby installed by Apple is for their use, and apps installed by Apple use it.

问题的标题“如何在 Mac 上将系统 Ruby 更新到 1.9.2”让我怀疑您是否正在尝试将 Apple 安装的 Ruby 1.8.7 升级到 1.9.2。如果这是真的,请停止并且不要尝试。Apple 安装的 Ruby 供他们使用,Apple 安装的应用程序使用它

find /usr -name '*.rb'

will list the reasons why.

将列出原因。

RVM and other apps allow you to install Ruby safely, so unless you have very good knowledge of how Unix and the Mac work I strongly recommend you stick to them.

RVM 和其他应用程序允许您安全地安装 Ruby,因此除非您非常了解 Unix 和 Mac 的工作原理,否则我强烈建议您坚持使用它们。

A very common problem we see is that the installation wasn't completed. Read the "Installation" section in the RVM installation page to double-check you've completed everything.

我们看到的一个非常常见的问题是安装未完成。阅读RVM 安装页面中的“安装”部分,仔细检查您是否已完成所有操作。

To install Ruby 1.9.2 do:

要安装 Ruby 1.9.2,请执行以下操作:

rvm notes

and read and install the needed dependencies. Then do:

并阅读并安装所需的依赖项。然后做:

rvm install 1.9.2
rvm use 1.9.2 --default

will tell RVM to always use 1.9.2 as a default. You can switch to the system version installed by Apple using:

将告诉 RVM 始终使用 1.9.2 作为默认值。您可以使用以下命令切换到 Apple 安装的系统版本:

rvm use system

and switch back using

并切换回使用

rvm default

回答by Phrogz

If you don't want an RVM-based solution:

如果您不想要基于 RVM 的解决方案:

  1. Download and install Apple's Xcode developer toolsso you get GCC et al, the ability to build your own software. (This is 4.25GB, but you only need to download it once.)
  2. Download and extract the Ruby Source Code. (10.6MB)
  3. Open a Terminal window and change into the directory of the source code.
  4. Run the command ./configure && make; get a cup of tea while you wait
  5. Run the command sudo make installto install this Ruby; you'll need to supply your administrator password
  6. Modify your PATHenvironment variable to put /usr/local/binin front of /usr/bin(so that your new Ruby is found before the system Ruby). You can do this by creating or editing a .profilefile in your home directory to have the line:
    export PATH="/usr/local/bin::$PATH"
    • If you're running TextMate, you'll also want to go to TextMate???Preferences???Advanced???Shell Variables
      and add or edit a PATHvariable like this:
      /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
  1. 下载并安装Apple 的 Xcode 开发人员工具,这样您就可以获得 GCC 等,即构建您自己的软件的能力。(这是 4.25GB,但您只需下载一次。)
  2. 下载并解压Ruby 源代码。(10.6MB)
  3. 打开终端窗口并切换到源代码目录。
  4. 运行命令./configure && make;等待时喝杯茶
  5. 运行命令sudo make install来安装这个 Ruby;您需要提供管理员密码
  6. 修改你的PATH环境变量放在/usr/local/bin前面/usr/bin(这样你的新 Ruby 在系统 Ruby 之前被发现)。你可以通过.profile在你的主目录中创建或编辑一个文件来做到这一点:
    export PATH="/usr/local/bin::$PATH"
    • 如果您正在运行 TextMate,您还需要转到 TextMate???Preferences???Advanced???Shell Variables
      并添加或编辑这样的PATH变量:
      /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

After this, rvm use systemwill use your 1.9.2p180 (the current version as of this post)install.

在此之后,rvm use system将使用您的 1.9.2p180 (本文中的当前版本)安装。

回答by Joseph Redfern

I'm assuming you're not sure how to install a new version of ruby with RVM - try:

我假设您不确定如何使用 RVM 安装新版本的 ruby​​ - 尝试:

rvm install 1.9.2

To then make it the default version to use:

然后使其成为要使用的默认版本:

rvm use 1.9.2 --default

回答by Ben Hyde

Consider also: "for OS X try using RailsInstaller for OS X or try the official RVM GUI JewelryBox" -- Quoted from from the 4rd or 5th screen the RVM install page found here http://rvm.io/rvm/install

还要考虑:“对于 OS X,尝试使用 RailsInstaller for OS X 或尝试官方的 RVM GUI JewelryBox”——引用自第 4 或第 5 个屏幕的 RVM 安装页面http://rvm.io/rvm/install

回答by don

Whatever you do do not touch or mess with the system default Ruby that ships with your Mac I did that to see what would and my system was out of whack. If you would like to use a different version of Ruby use rvm.

无论你不接触或弄乱 Mac 附带的系统默认 Ruby,我都这样做了,看看会发生什么,我的系统是否失灵了。如果您想使用不同版本的 Ruby,请使用 rvm。