How to update Ruby to 1.9.x on Mac?

前端 未结 9 1857
一个人的身影
一个人的身影 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:39

    I'll make a strong suggestion for rvm.

    It's a great way to manage multiple Rubies and gems sets without colliding with the system version.


    I'll add that now (4/2/2013), I use rbenv a lot, because my needs are simple. RVM is great, but it's got a lot of capability I never need, so I have it on some machines and rbenv on my desktop and laptop. It's worth checking out both and seeing which works best for your needs.

    0 讨论(0)
  • 2020-12-02 04:39

    As previously mentioned, the bundler version may be too high for your version of rails.

    I ran into the same problem using Rails 3.0.1 which requires Bundler v1.0.0 - v1.0.22

    Check your bundler version using: gem list bundler

    If your bundler version is not within the appropriate range, I found this solution to work: rvm @global do gem uninstall bundler

    Note: rvm is required for this solution... another case for why you should be using rvm in the first place.

    0 讨论(0)
  • 2020-12-02 04:40

    There are several other version managers to consider, see for a few examples and one that's not listed there that I'll be giving a try soon is ch-ruby. I tried rbenv but had too many problems with it. RVM is my mainstay, though it sometimes has the odd problem (hence my wish to try ch-ruby when I get a chance). I wouldn't touch the system Ruby, as other things may rely on it.

    I should add I've also compiled my own Ruby several times, and using the Hivelogic article (as Dave Everitt has suggested) is a good idea if you take that route.

    0 讨论(0)
  • 2020-12-02 04:43

    I know it's an older post, but i wanna add some extra informations about that. Firstly, i think that rvm does great BUT it wasn't updating ruby from my system (MAC OS Yosemite).

    What rvmwas doing : installing to another location and setting up the path there to my environment variable ... And i was kinda bored, because i had two ruby now on my system.

    So to fix that, i uninstalled the rvm, then used the Homebrew package manager available here and installed ruby throw terminal command by doing brew install ruby.

    And then, everything was working perfectly ! The ruby from my system was updated ! Hope it will help for the next adventurers !

    0 讨论(0)
  • 2020-12-02 04:44

    I'll disagree with The Tin Man here. I regard rbenv as preferable to RVM. rbenv doesn't interfere drastically with your shell the way RVM does, and it lets you add separate Ruby installations in ordinary folders that you can examine directly. It allows you to compile Ruby yourself. Good outline of the differences here: https://github.com/sstephenson/rbenv/wiki/Why-rbenv%3F

    I provide instructions for compiling Ruby 1.9 for rbenv here. Further, more detailed information here. I have used this technique with easy success on Snow Leopard, Lion, and Mountain Lion.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题