How to update Ruby to 1.9.x on Mac?

前端 未结 9 1963
一个人的身影
一个人的身影 2020-12-02 04:15

I have created a new user account on my mac and I am trying to update to the current version of ruby on it (1.9.2) from the snow leopard default of 1.8.7. Can somebody point

9条回答
  •  感情败类
    2020-12-02 04:49

    As The Tin Man suggests (above) RVM (Ruby Version Manager) is the Standard for upgrading your Ruby installation on OSX: https://rvm.io

    To get started, open a Terminal Window and issue the following command:

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

    ( you will need to trust the RVM Dev Team that the command is not malicious - if you're a paranoid penguin like me, you can always go read the source: https://github.com/wayneeseguin/rvm ) When it's complete you need to restart the terminal to get the rvm command working.

    rvm list known
    

    ( shows you the latest available versions of Ruby )

    rvm install ruby-2.3.1
    

    For a specific version, followed by

    rvm use ruby-2.3.1
    

    or if you just want the latest (current) version:

    rvm install current && rvm use current
    

    ( installs the current stable release - at time of writing ruby-2.3.1 - please update this wiki when new versions released )

    Note on Compiling Ruby: In my case I also had to install Homebrew http://mxcl.github.com/homebrew/ to get the gems I needed (RSpec) which in turn forces you to install Xcode (if you haven't already) https://itunes.apple.com/us/app/xcode/id497799835 AND/OR install the GCC package from: https://github.com/kennethreitz/osx-gcc-installer to avoid errors running "make".

    Edit: As of Mavericks you can choose to install only the Xcode command line tools instead of the whole Xcode package, which comes with gcc and lots of other things you might need for building packages. It can be installed by running xcode-select --install and following the on-screen prompt.

    • Examples: https://rvm.io/workflow/examples/
    • Screencast: http://screencasts.org/episodes/how-to-use-rvm

    Note on erros: if you get the error "RVM is not a function" while trying this command, visit: How do I change my Ruby version using RVM? for the solution.

提交回复
热议问题