March 04, 2007

Posted by John

Tagged subversion

Older: Renaming RHTML to ERB

Newer: Snitch: Tattling on your Subversion Commits

How To Pimp Your Local Rails Setup

So after reading Mike Clark’s Managing Rails Versions With Capistrano, I completely switched how I use rails locally as well. I try to stay as close to the edge of Rails as possible because I’m addicted to new.

The Problem

Formerly, I would rake rails:freeze:edge into my apps and even in my svn repositories. Yes, I know of svn:externals but for some reason I just didn’t like updating rails in that way. Freezing rails into your repository makes it a PAIN to update to a new revision. Each time some cool new feature came out, I had to svn rm vendor/rails and then svn commit and then rake rails:freeze:edge and then svnaddall (my alias for adding all the non version controlled files into version control) and then svn commit again. Inevitably, something would go wrong during that process and I would spend half an hour on it.

The other kicker is that I had to do this for each of my apps. After reading Mike’s article it struck me that I could do the same thing on my local machine that he is doing for remote versions. Here are the commands that I use to setup each of my macs (this is kind of from memory, but hopefully you catch my drift).

The Solution

Below is my chicken scratch on the whiteboard in my office of how it works. I was explaining it to Chas and Bill.

New Local Machine Rails Setup

First, create a rails directory in your user folder and checkout rails trunk inside it:

$ mkdir ~/rails
$ cd ~/rails
$ svn co http://dev.rubyonrails.com/svn/rails/trunk .

Now cd into your app and setup a symlink to the trunk folder you just created in your vendor folder:

$ cd ~/Sites/myrailsapp
$ ln -s ~/rails/trunk vendor/rails

If you are using subversion, you can ignore the symlink so it doens’t try to version it:

$ svn propset svn:ignore "rails" vendor/
$ svn commit -m "using new sweet rails setup"
$ svn up

After that, your rails app will be running on the freshest version of rails and is fully ignoring rails in subversion. Now, when you see a changeset come through (you are watching the changesets aren’t you), all you have to do to update your app and any others that you are running like this is:

cd ~/rails/trunk && svn up

Or, if you don’t want to have all your apps running on edge, you can checkout a specific revision to your rails folder and link to that like so:

$ cd ~/rails
$ svn co -r 6000 http://dev.rubyonrails.org/svn/rails/trunk Rev_6000
$ cd ~/Sites/myrailsapp
$ ln -s ~/rails/Rev_6000 vendor/rails

You can then update to a new revision by following the steps above and then doing:

$ cd ~/Sites/myrailsapp
$ rm -f vendor/rails
$ ln -s ~/rails/Rev_6001 vendor/rails

I’ve been using this setup for a few weeks and am loving it (especially, with the flurry of activity of late).

4 Comments

  1. So, for clarification, are you symlinking all your apps into that one Rails dir? That would seem like the way to go to me – DRY.

    I hadn’t thought about that till your post, thanks!

  2. @Robert – Exactly. No problem. Thank Mike Clark as well for the capistrano idea. That’s where mine came from.

  3. One thing missing on your svn co line is the period on the end, otherwise svn will end up creatng ~/rails/trunk

  4. @Mark – Thanks. I believe I fixed the one you were talking about. Let me know if I missed it.

Thoughts? Do Tell...


textile enabled, preview above, please be nice
use <pre><code class="ruby"></code></pre> for code blocks

About

Authored by John Nunemaker (Noo-neh-maker), a programmer who has fallen deeply in love with Ruby. Learn More.

Projects

Flipper
Release your software more often with fewer problems.
Flip your features.