Having recently reformatted my Mac, I thought I’d jot some notes down on setting up a Ruby dev environment too.
In this post we’ll set up our fresh dev enviroment for Ruby, and cover installing and setting up the following…
- Command line tools
Xcode or GCC
Simply download and install Xcode from the App store, OR, get GCC from here.
Command Line Tools
Once Xcode has installed, open it, then go to preferences > downloads, and install command line tools. Or alternatively, enter this in terminal:
In the terminal copy and paste the following:
Chruby, Rubygems, Rails, Git, ImageMagick
Chruby is the new Ruby version manager that most Ruby devs seem to be using and recommending nowadays. I recently tried it and like it too! (Note, not to be installed if you have or intend to use RVM or Rbenv.)
brew install chruby
brew install ruby-install
ruby-install ruby 2.2.2
In ‘~/.bash_profile’ add the following lines:
Which makes Ruby 2.2.2 the default Ruby. Then simply add a .ruby-version file with the Ruby version you would like (e.g ‘2.2.2’) for that directory and all directories inside it unless they specify their own .ruby-version. Easy huh!?
You’re rubies are now either in /opt/rubies or ~/.rubies.
Update RubyGems and install Rails
Now for Rails:
Restart terminal and check your versions by:
Update Homebrew and let’s get brewing!
Let’s update Homebrew and install some software to get you going; ImageMagic, Git and Postgres.
brew install ImageMagick
brew install git
brew install postgres
Then to start Postgres and on startup, run the lines it tells you to, mine were:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Then create your initial db:
CREATE ROLE postgres LOGIN CREATEDB;
to create your posters user and check it works ok (use CTRL Z to come out).
Finally you need a decent editor! Personally I use MacVim and sometimes TextMate 2.
Get TextMate 2 from here.
To install MacVim:
Get the latest snapshot from here and double click then move to your applications folder (or you can do ‘brew install macvim’).
Once installed, you’ll want to drag the ‘mvim’ file to your desktop, and then in terminal:
This allows you to use ‘mvim’ in the terminal.
Next you’ll want to use Janus, which can be installed by running this in terminal:
That’s it! Tho, if you want to learn more about Vim, Janus or install a nice theme, check out this post