Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Installing a Ruby Development Environment Installing a Ruby Development Environment Installing Ruby on Mac

Shawn Flanigan
Shawn Flanigan
Courses Plus Student 15,815 Points

What are we doing here (Installing Ruby on Mac)?

Just followed along with the "Installing Ruby on on Mac" video...and Ruby is installed, but I seriously have no idea what I did...just struggled to follow along. Can anyone enlighten me as to what I've just done and why?

I'm sure these steps will be helpful later on in the course, but this seemed like a step-by-step how-to video with little educational value. Did I miss something?

1 Answer

Stone Preston
Stone Preston
42,016 Points

this seemed like a step-by-step how-to video with little educational value

Welcome to the Rails Track!

Seriously though, thats my main complaint about the rails courses. Dont get me wrong the content is still pretty good, its just Jason kind of speeds through things and doesnt every really stop and provide any explanation. Most of the time I felt really lost and never understood why I did anything other than that it needed to happen for something to work.

If you are serious about getting into rails, I would read a free and highly regarded eBook by Michael Hartl (harvard/caltech educated physicist turned web developer) that can be found here. It provides a detailed guide on developing a rails application from scratch without using scaffolding like the courses on TTH do. Its extremely well written and I highly recommend doing it first before the TTH courses so you have an actual idea of whats going on. Its 12 chapters that are all pretty long and probably takes about a week of steady work to get through

Rails development is daunting. It is probably unlike anything you have encountered before and has a very steep learning curve so having a basic knowledge of it before watching the TTH videos will help immensely

Rails development makes heavy use of the command line, so you might check out the Console Foundations course to get comfortable using the command line

I skimmed through the video so I may have missed something but this was the gist:

first you clone the rbenv git repo to "install it" in a sense. rbenv is a tool that helps install and manage your ruby versions (since you can have multiple different versions installed). without a version manager such as rbenv or rvm, it can get quite messy. cloning this repository basically gives you your own personal copy on your system

$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv

next you need to add rbenv to your $PATH by appending a command in the .bash_profile file.

the >> syntax "pipes" the output of the echo statement into the .bash_profile file, which adds the command to the filethe commands in this file are executed when you login to a terminal session.

the $PATH variable is a list of directories that bash (the program executing commands in your terminal window) looks in whenever you type a command. it goes through every single directory thats listed in the $PATH variable until it finds the command you specified. Without adding the path to rbenv to your $PATH variable, bash would return an error that the command was not found.

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

next you Add rbenv init to your shell to enable shims and autocompletion (no idea what this does sorry)

$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

then you restart your terminal and verify rbenv is a recognized command by checking the version number

$ rbenv -v

next you clone the ruby build rbenv plugin to install it into your rbenv plugins

$ git clone https://github.com/sstephenson/ruby-build.git

then you install ruby using rbenv

$ rbenv install 2.0.0-p247

if you dont have a compiler on your system, you need to install the xcode CLT which will allow you to build files from source code (compile stuff)

next you set your global ruby version (the version thats used by default)

$ rbenv global 2.0.0-p247

then you install bundler which handles installing and managing gems used in ruby and rails development

gem install bundler

then you install the rails gem

gem install rails

then using the newly installed rails gem you create a new rails application

rails new some_app

then you start the rails server and navigate to the localhost IP to make sure everything is working

rails server
Shawn Flanigan
Shawn Flanigan
Courses Plus Student 15,815 Points

Thanks for the thorough explanation, Stone! Glad to hear I'm not alone here...I thought maybe I just wasn't paying close enough attention. I'll definitely check out the ebook before continuing with the track.