Full Stack Ruby on Rails Development for Snow Leopard

This article is gonna talk about setting up Ruby, RubyGems, SVN, Git, Rails and MySQL for Snow Leopard.  There’s a few other articles that go really in depth with setting up custom server configurations for Snow Leopard, but I found them to be doing more than I need for my personal development (here http://www.metaskills.net/2009/9/5/the-ultimate-os-x-snow-leopard-stack-for-rails-development-x86_64-macports-ruby-1-8-1-9-sql-server-more). 
Disclaimer: This setup worked for me twice, once on a MBP and once on a 27” iMac i5.  I can’t guarantee it’ll work for you.  If you run into issues, feel free to leave a comment, but I can’t promise I’ll know the answer.

I’ve setup two different Snow Leopard computers in the past couple days to do this, and I’ve compiled some notes on what worked for me.
To start off, install MacPorts: http://www.macports.org/install.php following their instructions: http://guide.macports.org/

If you’re like me, you use Bash as your default shell, so add this to your ~/.profile 
export PATH="/usr/local/bin:$PATH" export MANPATH="/usr/local/share/man:$MANPATH" export INFOPATH="/usr/local/share/info:$INFOPATH" 

Chances are, if you’re using Snow Leopard, you’re running 64-bit apps and you have a chip that supports 64-bit architecture.  If it does, you can force MacPorts to install apps with 64-bit architecture.  Open up 
/opt/local/etc/macports/macports.conf 

 And change the “build_arch” setting (around line 59) to x86_64.
Once that’s done, you’re ready to install Ruby.

sudo port install ruby
It’ll take awhile, so go grab a cup of coffee or something while you wait.  Once that’s done, running “which ruby” should show 

/opt/local/bin/ruby 
And running “ruby -v” should show

ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10]
Next step is rubygems, “sudo port install rb-rubygems”.

After that is SVN and Git, “sudo port install subversion” and “sudo port install git-core +svn”
Next up is MySQL.  At the time of writing this, no package for Mac OS 10.6 has been released.  So download the 10.5 x86_64 package from here http://dev.mysql.com/downloads/mysql/5.1.html#macosx-dmg.  

Install both packages and the PrefPane (for some reason the pref pane is still 32-bit so it’ll ask you to restart System Preferences every time you use it).
In order to access MySQL from the command line, add this to your ~/.profile

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH" 
Then run “source ~/.profile” in order to refresh your shell.

After installing Rails, you need to install the MySQL adapter gem: “sudo env ARCHFLAGS=”-arch x86_64” gem install mysql — —with-mysql-config=/usr/local/mysql/bin/mysql_config”
That particular command will tell it to instal the x86_64 version of the gem, and points it to your mysql config files.

Lastly, install Rails.  ”sudo gem install rails”.  This will install about 8 different gems, and take a few minutes.
Afterwards, you can test this all by running, “rails testapp -d mysql” then “cd testapp” then “rake db:create:all” then “./script/server” and browsing to “http://localhost:3000”.  

You should see the attached screen shots.

See and download the full gallery on posterous

Posted via email from Jared McFarland | Comment »

@2 years ago