Install Ruby For Mac Os X



We will be setting up a Ruby on Rails development environment on Mac OS X 10.11 El Capitan. Older versions of OS X are mostly compatible so follow along as far as you can and then Google search for any problems you run into. There are plenty of people who have documented solutions for them. I am reading the book Programming Ruby and am looking to upgrade the version of Ruby on my computer. I run Mac OS X Snow Leopard and doing ruby -v in the command line shows I am running Ruby 1.8.7. I installed MacPorts and ran the sudo port install ruby19 command but whenever I type ruby -v, it still shows Ruby 1.8.7. Could anyone help with this? The following instructions for installing Ruby have been tested on Mac OS X Yosemite (10.10.4). They should work fine with Mac OS X El Capitan (10.11.1) or Mavericks (10.9.5) as long as you’re running the latest updates for that version of Mac OS X. This will take about 30 minutes. We will be setting up a Ruby on Rails development environment on Mac OS X 10.11 El Capitan. Older versions of OS X are mostly compatible so follow along as far as you can and then Google search for any problems you run into. I've written an in depth guide to installing Ruby on Rails on Mac OS X 10.9 Mavericks. It's here: Install Ruby on Rails Mac OS X Mavericks. It explains how to set up the Mac (with Xcode Command Tools), install Ruby with RVM (the Ruby Version Manager), and install Rails, with advice about updating important gems and setting up a professional development environment.

  1. Mac Os X Mavericks Installer Download
  2. Mac Os Install Disc Download
  3. Install Ruby For Mac Os X 10 11
  4. Install Ruby For Mac Os X High Sierra Download
  5. Install Ruby In Mac
  6. Mac Os X Download

Most developers spend their first day on a new computer setting up their develoment environment. If you are a ruby developer, this article should help you get started quickly.

I’m assuming you are starting with a clean install of Mac OS X Lion. A similar environment could be created off of the same or similar tools for a Linux machine.

The pieces of this development environment are:

  • rbenv
  • ruby-build
  • ruby
  • bundler
  • rails
  • MySQL
  • redis
  • pow

This should give you a broad set of tools that will cover most development environment needs. You could easily add more tools to your environment if needed.

Install Xcode

Xcode provides many of the necessary compilers and libraries needed for your development environment.

As of Lion, this is an easy install via the Mac App Store. It is a large download so while this step is easy, it will take some time to download and install.

The following link will take you to the Mac App Store to install.

Install Homebrew

Homebrew is the easiest and most flexible way to install the UNIX tools Apple didn’t include with OS X.

To install run the following command:

You can see detailed instructions on what happens when you run this command to install here:

Remove RVM (if necessary)

If you have previously used RVM in your environment, you’ll want to get rid of this so it doesn’t interfere with your new environment. This is a simple task. Just run:

Install MySQL Server

Now that we have homebrew installed, these installations become simple single line commands.

Install Redis (optional)

Redis is an open source, advanced key-value store. It has many uses such as caching and serving as a queue for background jobs (via resque).

Once again, an easy to install with homebrew.

Install rbenv and ruby-build

The basis of this environment is rbenv which allows you to run self-contained ruby environments for each of your projects. This setup has huge advantages over a system wide install of ruby that would force you to keep all of your projects on the same version of ruby as well as gems.

I chose rbenv over rvm because it’s simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.

Use homebrew to install.

Add to ~/.bash_profile:

I like to alias the `bundle exec` command to just `b` to save some typing. If you prefer not to do that, just skip adding that line to the .bash_profile.

Restart your Terminal.

Mac Os X Mavericks Installer Download

Install pow

Pow is a zero-config Rack server for Mac OS X. Instead of running the rails server manually for each of your projects, pow runs it for you and gives you a simple hostname to. So instead of going to http://localhost:3000 after starting your rails server, you can just go straight to http://project.dev (where “project” is replaced with the folder name of your project.

Note: I’ve had trouble using pow before when using custom DNS servers in my Network settings. If something isn’t working right when you try to use pow, check your DNS settings and make sure you are using the defaults.

To install pow, simply run:

You can view this script before running it on their website.

Install ruby

Now we can install our rubies. At the time of writing this I had projects running on both 1.8.7 and 1.9.3 so I’m going to show you how to setup both and set one as the global version.

Install ruby 1.9.3:

Install ruby 1.8.7:

After installing a new ruby or a global gem, you need to run the following command.

Set the global ruby to 1.9.3:

Configure your global gem settings

I typically always just use Google and the online documentation for ruby, rails, and other gems. So installing the rdoc’s for all of our gems is a waste. I prefer to disable this in a .gemrc file.

Add this line to the ~/.gemrc file:

Install bundler

Bundler manages an application’s dependencies through its entire life across many machines systematically and repeatably.

Bundler has to be installed for each version of ruby you want to run it on.

Configure bundler in ~/.bundle/config:

This line tells bundler to install my gems in a relative path specific to each project.

Install Rails

Similar to bundler, you want to install the rails gem for each of your ruby versions.

Setup your first Rails project

Now you’re ready to setup your first project. We are going to create a sample project called “blog”.

Create a projects folder if you don’t already have one.

Remember that we want to use MySQL as the database for the Rails project so we are going to pass that in with the rails command.

Set the project specific ruby version.

This sets a local per-project Ruby version by writing the version name to an .rbenv-version file in the current directory.

Now run bundler on your new project.

Mac Os Install Disc Download

This will install all of the gems for this project into:

Install Ruby For Mac Os X 10 11

If you ever get into a situation where your gems are working correctly, you can simple delete that entire bundle directory and run bundle install again to get fresh versions of everything for your project.

To setup pow for your new rails project, just create a symbolic link to the project folder in the ~/.pow directory.

Install Ruby For Mac Os X High Sierra Download

That’s it! Now you should be able to access your new project at:

Other apps you might want

Install Ruby For Mac Os X

GitHub

I highly recommend using GitHub to host your projects. They offer a free app for working with git repositories and it makes it super easy to use with their service.

Sublime Text 2

Install Ruby In Mac

This is the text editor I use and prefer. It has a lot of cool features and is very customizable.

MySQL Workbench

Mac Os X Download

MySQL offers a free app for managing your MySQL databases.