Installing Ruby on Mac and Linux - Ruby Wizardry: An Introduction to Programming for Kids (2014)

Ruby Wizardry: An Introduction to Programming for Kids (2014)

Appendix A. Installing Ruby on Mac and Linux

Installing on Mac

New Macs ship with Ruby 2.0 already installed, so if you’re here, you’re likely using an older Mac that has Ruby 1.8.7. Not to worry! We’ll get you upgraded in a jiffy.

Open up your terminal and type the following code. (The $ just shows you where to start typing—don’t type the $!) This will install a tool called RVM (Ruby Version Manager) as well as Ruby 2.0.

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

--auto-dotfiles

Once you do this, you’ll see a whole bunch of text pop up to tell you that your computer is downloading Ruby. When it’s all done, close your terminal, reopen it, and enter ruby -v. You should see your computer print a response with ruby 2.0.0 in it!

If your Ruby version still isn’t Ruby 2.0, you can try installing it using the Homebrew package manager. First, install Homebrew:

$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/

install)"

Once that command completes successfully, you can simply type this:

$ brew install ruby

At the time of this writing, Homebrew automatically installs Ruby 2.1.3. This is just a slightly newer version than Ruby 2.0, and it will work with the code examples in this book.

Installing on Linux

Open up your terminal and type the following code. (The $ just shows you where to start typing—don’t type the $!) This will install a tool called RVM (Ruby Version Manager) as well as Ruby 2.0.

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

dotfiles

Once you do this, you’ll see a whole bunch of text pop up to tell you that your computer is downloading Ruby. When it’s all done, close your terminal, reopen it, and enter ruby -v. You should see your computer print a response with ruby 2.0.0 in it!

If you get an error or your computer tells you that Ruby isn’t installed, grab your trusty adult and check out the Ruby installation page at https://www.ruby-lang.org/en/installation/. There may be a recent package designed especially for your version of Linux, and it may be easier to use that package to install Ruby, rather than using RVM. You can also ask your adult to go on IRC and get help from the folks in the #ruby channel.