How to update Ruby Version 2.0.0 to the latest version in Mac OSX Yosemite?

RubyVersion

Ruby Problem Overview


I need to update my ruby version from 2.0.0 to the latest version, I can not use some gems because my version is not updated. I had used Homebrew to install Ruby some time ago, How can i update my Ruby version?

Ruby Solutions


Solution 1 - Ruby

Open your terminal and run

curl -sSL https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer | bash -s stable

When this is complete, you need to restart your terminal for the rvm command to work.

Now, run rvm list known

This shows the list of versions of the ruby.

Now, run rvm install ruby@latest to get the latest ruby version.

If you type ruby -v in the terminal, you should see ruby X.X.X.

If it still shows you ruby 2.0., run rvm use ruby-X.X.X --default.

Prerequisites for windows 10:

  • C compiler. You can use http://www.mingw.org/
  • make command available otherwise it will complain that "bash: make: command not found". You can install it by running mingw-get install msys-make
  • Add "C:\MinGW\msys\1.0\bin" and "C:\MinGW\bin" to your path enviroment variable

Solution 2 - Ruby

Brew only solution

Update:

From the comments (kudos to Maksim Luzik), I haven't tested but seems like a more elegant solution:

> After installing ruby through brew, run following command to update the links to the latest ruby installation: brew link --overwrite ruby

Original answer:

Late to the party, but using brew is enough. It's not necessary to install rvm and for me it just complicated things.

By brew install ruby you're actually installing the latest (currently v2.4.0). However, your path finds 2.0.0 first. To avoid this just change precedence (source). I did this by changing ~/.profile and setting:

export PATH=/usr/local/bin:$PATH

After this I found that bundler gem was still using version 2.0.0, just install it again: gem install bundler

Solution 3 - Ruby

I recommend rbenv* https://github.com/rbenv/rbenv

* If this meets your criteria: https://github.com/rbenv/rbenv/wiki/Why-rbenv?:

> ### rbenv does… > > * Provide support for specifying application-specific Ruby versions. > * Let you change the global Ruby version on a per-user basis. > * Allow you to override the Ruby version with an environment variable. > > ### In contrast with RVM, rbenv does not… > > * Need to be loaded into your shell. Instead, rbenv's shim approach works by adding a directory to your $PATH. > * Override shell commands like cd or require prompt hacks. That's dangerous and error-prone. > * Have a configuration file. There's nothing to configure except which version of Ruby you want to use. > * Install Ruby. You can build and install Ruby yourself, or use ruby-build to automate > the process. > * Manage gemsets. Bundler is a better way to manage application dependencies. If you have projects that are > not yet using Bundler you can install the > rbenv-gemset plugin. > * Require changes to Ruby libraries for compatibility. The simplicity of rbenv means as long as it's in your $PATH, > nothing > else needs to know about it.


INSTALLATION

Install Homebrew http://brew.sh

Then:

$ brew update
$ brew install rbenv 
$ brew install rbenv ruby-build

Add rbenv to bash so that it loads every time you open a terminal

echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile source ~/.bash_profile

> UPDATE
> There's one additional step after brew install rbenv Run rbenv > init and add one line to .bash_profile as it states. After that > reopen your terminal window […] SGI Sep 30 at 12:01 —https://stackoverflow.com/users/119770

$ rbenv install --list
Available versions:
1.8.5-p113
1.8.5-p114
[…]
2.3.1
2.4.0-dev
jruby-1.5.6
[…]
$ rbenv install 2.3.1
[…]

Set the global version:

$ rbenv global 2.3.1
$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

Set the local version of your repo by adding .ruby-version to your repo's root dir:

$ cd ~/whatevs/projects/new_repo
$ echo "2.3.1" > .ruby-version

For MacOS visit this link

Solution 4 - Ruby

Open Terminal:

sudo gem update --system 

It works!

Solution 5 - Ruby

Fast way to upgrade ruby to v2.4+

brew upgrade ruby

or

sudo gem update --system 

Solution 6 - Ruby

You can specify the latest version of ruby by looking at https://www.ruby-lang.org/en/downloads/

  1. Fetch the latest version:

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

  2. Install it:

    rvm install 2.2

  3. Use it as default:

    rvm use 2.2 --default

Or run the latest command from ruby:

rvm install ruby --latest
rvm use 2.2 --default

Solution 7 - Ruby

brew install rbenv ruby-build

Add rbenv to bash so that it loads every time you open a terminal

echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile

source ~/.bash_profile

Install Ruby

rbenv install 2.6.5

rbenv global 2.6.5

ruby -v

Solution 8 - Ruby

In case anyone gets the same error I did: “Requirements installation failed with status: 1.” here's what to do:

Install Homebrew (for some reason might not work automatically) with this command:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then proceed to install rvm again using

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

Quit and reopen Terminal and then:

rvm install 2.2
rvm use 2.2 --default

Solution 9 - Ruby

In terminal : rvm gemset use global

Solution 10 - Ruby

If you are on mac, Use rvm to install your specific version of ruby. See https://owanateamachree.medium.com/how-to-install-ruby-using-ruby-version-manager-rvm-on-macos-mojave-ab53f6d8d4ec

Make sure you follow all the steps. This worked for me.

Solution 11 - Ruby

Simplest way is definitely to enter the following command in the terminal:

sudo gem update --system

You can add the flag --no-document if you do not want to download the documentation. Here is sample output after running the command:

sudo gem update --system
Password:
Updating rubygems-update
Fetching: rubygems-update-2.6.8.gem (100%)
Successfully installed rubygems-update-2.6.8
Parsing documentation for rubygems-update-2.6.8
Installing ri documentation for rubygems-update-2.6.8
Installing darkfish documentation for rubygems-update-2.6.8
Installing RubyGems 2.6.8
RubyGems 2.6.8 installed
Parsing documentation for rubygems-2.6.8
Installing ri documentation for rubygems-2.6.8

------------------------------------------------------------------------------

RubyGems installed the following executables:
	/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/gem

Ruby Interactive (ri) documentation was installed. ri is kind of like man 
pages for ruby libraries. You may access it like this:
  ri Classname
  ri Classname.class_method
  ri Classname#instance_method

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionChuchaCView Question on Stackoverflow
Solution 1 - RubyAbhinay Reddy KeesaraView Answer on Stackoverflow
Solution 2 - RubySergio BasurcoView Answer on Stackoverflow
Solution 3 - RubySoAwesomeManView Answer on Stackoverflow
Solution 4 - RubyCristianetoo GeovaView Answer on Stackoverflow
Solution 5 - RubyfatihyildizhanView Answer on Stackoverflow
Solution 6 - Rubyjulien bouteloupView Answer on Stackoverflow
Solution 7 - RubyKarats MohanrajView Answer on Stackoverflow
Solution 8 - RubyPaula HasstenteufelView Answer on Stackoverflow
Solution 9 - RubyAramisView Answer on Stackoverflow
Solution 10 - RubyFungieView Answer on Stackoverflow
Solution 11 - RubyReza MalikView Answer on Stackoverflow