"Java Data Structures - Retired" was retired on May 31, 2019. You are now viewing the recommended replacement.
Start a free Courses trial
to watch this video
Today, we're going to be setting up a Ruby on Rails development environment on a Mac.
First, you'll need to open a terminal. If you haven't done this before, visit your Applications folder in the Finder, then open the "Utilities" folder, and double-click the "Terminal" app. Once that's done, you'll be ready to follow along for the rest of these directions.
Homebrew
Installing Rails requires several software packages. And Homebrew, the package manager, can automatically download and install these packages for us. So let's start by installing Homebrew.
Copy and paste this Ruby command into your terminal, then hit the Return key to run it:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
(Macs actually come with a version of Ruby pre-installed. It's a bit outdated, but it's recent enough to install Homebrew for us.)
When the install finishes, you'll see the dollar sign prompt again. Now it's time to install our first Homebrew package. For security reasons, we're going to need an encryption tool named "gpg", so let's install that. In your terminal, run:
brew install gpg
Wait a bit, and when it returns to the command prompt, the gpg software will be installed.
Ruby Version Manager (rvm)
And now we're ready to install rvm, the Ruby Version Manager. rvm will download, compile, and install new Ruby versions for us.
Copy and paste these two commands into your terminal:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable
(Yes, that is a backslash before the "curl" command. It's there to avoid potential version conflicts.)
rvm is now installed, but it won't be available until you open a new terminal window. So go ahead and open a new window from the menu. Then, try running the "rvm" command all by itself. If it outputs usage information, you'll know it's working.
Ruby
Now that rvm is installed, we can have it install a new Ruby version for us. Run this command from your terminal:
rvm install 2.3.1
When it returns to the system prompt, Ruby will be installed. But it may not be available in your terminal yet. To tell rvm to use the Ruby version you just installed, and to use this version by default in the future, run this command in your terminal:
rvm use 2.3.1 --default
Rails
Now it's time to install Rails. Rails comes as a Ruby "gem". A gem is a library, a collection of reusable code, that can be automatically downloaded and installed on your system, using the "gem" tool. In your command prompt, run:
gem install rails --version 5.0.0
The "gem" program will download and install that version of the Rails gem, along with all the other gems Rails depends on.
That's it! You should be ready to create your first Rails app!
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up[MUSIC] 0:00 Hi, I'm Jay, a teacher here at Tree House. 0:04 Today we're going to be setting up a Ruby on Rails development environment 0:07 on your Mac. 0:10 We'll use Homebrew, a software package installer to install some libraries that 0:11 both Ruby on Rails rely on. 0:15 Then we use RVM, the Ruby Version Manager, to install a new version of Ruby. 0:17 Macs already come with a version of Ruby installed but 0:22 it's usually a little out of date. 0:25 RVM will install an up to date version alongside your existing version. 0:27 Lastly we'll use our newly installed Ruby tools to install the Rails library itself. 0:31 We've tried to make this guide applicable for as many people as possible but 0:36 small tweaks may be needed to get your system working. 0:40 Be sure to check the teacher's notes for additional hints. 0:43 And if you get stuck try asking your question in the Tree House community. 0:45 If you're getting an error message, copy and 0:49 paste that into your post as you'll get help more quickly that way. 0:51 Ready? 0:55 Let's get started. 0:55 First you'll need to open a terminal. 0:58 If you haven't done this before, visit your Applications folder in the Finder. 0:59 Then open the Utilities folder. 1:04 And then double-click the Terminal lab. 1:06 Installing Rails requires several software packages and Homebrew, the package 1:09 manager, can automatically download and install these packages for us. 1:13 So, let's start by installing Homebrew. 1:17 In a search engine, search for Homebrew. 1:19 You're looking for the package manager so click that link. 1:22 You'll see a Ruby command that you need to copy and paste into your terminal. 1:25 Macs actually come with a version of Ruby pre-installed. 1:29 It's a bit outdated, but it's recent enough to install Homebrew for us. 1:32 So select the command. 1:36 Copy it. 1:38 Now paste the terminal into your command and hit Enter to run it. 1:40 It will ask you to confirm. 1:43 So just press Return. 1:45 And you'll need to type your system password. 1:47 Now it's time to install our first Homebrew package. 1:56 For security reasons we're going to need an encryption tool named GPG. 2:00 So let's install that. 2:04 In your terminal type brew install gpg. 2:05 And now we're ready to install RVM the Ruby Version Manager. 2:14 RVM will download, compile and install new Ruby versions for us. 2:18 In a search engine search for our RVM. 2:22 It'll probably be the first result. 2:26 Scroll down a bit and you'll see a pair of commands that you need to copy and 2:29 paste into your terminal. 2:34 Highlight the gpg command. 2:36 Don't include the dollar sign at the start as that's meant to represent you system 2:37 command prompt. 2:41 Now Copy and then Paste the command into your terminal. 2:42 Hit Return and wait for the command to complete. 2:46 Now for the second command, go back to your browser, select the second command, 2:50 again without the dollar sign. 2:54 Copy and paste into your terminal. 2:56 Hit Enter to run. 2:58 RVM is now installed but 3:02 it won't be available until you open a new terminal window. 3:04 So go ahead and go into your menu and choose to open a new window. 3:07 You can confirm that your ruby installation is successful by typing ruby 3:13 –v at the prompt. 3:17 It should bring up the Ruby version. 3:18 Okay, Ruby is installed. 3:20 Now it's time to install Rails. 3:22 Rails comes as a Ruby gem. 3:24 A gem is a library, a collection of reusable code. 3:26 Gems can be automatically downloaded and 3:29 installed on your system using the gem tool. 3:31 In your command prompt type gem install 3:34 followed by the name of the gem we want which is rails. 3:38 But don't run the command yet. 3:41 If you want to simply install the latest version of Rails 3:42 whatever it was you could just hit Return here. 3:45 But we want to specify a particular version of Rails to install to make sure 3:48 that all the code we show you during the upcoming courses will work the same way. 3:51 So, we're going to add --version 5.0.0 onto the end of the command. 3:56 Once you press Return, the gem program will download and install version 5.0.0 4:05 of the Rails gem along with all the other gems Rails depends on. 4:10 There's a lot of them so be patient. 4:14 You'll know the installation is done when you see your system prompt again. 4:16 And that's it. 4:24 You should be ready to create your first Rails app. 4:25
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up