Installing and managing edge Rails

By Tim Lucas

By request, I’ll give you a quick rundown on how to develop against the latest version of Rails. Why would you want to do this? You might be working on a brand new app that’ll be in development for a while, so stability is not a great concern. Maybe you wanna be the cool kid on the block playing with as-yet-unreleased features. Whatever the case, here’s how you do it.

By default, when you start a Rails app it attempts to use Rails from your project’s vendor/rails directory. If it can not be found it’ll fall back on the latest gem.

To use edge Rails on an existing project, just do an svn checkout of the rails trunk into your vendor/rails directory inside your project.

svn co vendor/rails

If you’re starting a new project, you can check out Rails from SVN and then use it to create your new project. All the following commands are for *nix-based platforms. If you’re a windows user you’ll have to adapt accordingly (and maybe leave a comment for others?)

mkdir -p cutting_edge_project/vendor
cd cutting_edge_project
svn co vendor/rails
ruby vendor/rails/railties/bin/rails .
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)

If you want to sync your version of Rails with the latest version of SVN, just execute an svn update command on the rails directory (and don’t forget to restart your server).

svn update vendor/rails

If the trunk version of Rails is broken and you want to rollback to a specific revision, pass the revision to the update command with -r.

svn update -r4598 vendor/rails

If you’re managing your project in SVN chances are you don’t want to check out the Rails trunk into your vendor directory, but instead you want to an svn export or make use of svn:externals.

To create a new edge Rails that will be checked into SVN:

mkdir -p cutting_edge_svn_project/vendor
cd cutting_edge_svn_project
svn export vendor/rails
ruby vendor/rails/railties/bin/rails .
rm -R vendor/rails
# prepare project for SVN (i.e. delete logs, etc) and import

Once you’ve checked out a copy of your project, into say my_checked_out_project, set the svn:externals property of the vendor directory and do an svn update:

cd my_checked_out_project
svn propset svn:externals "rails" vendor
svn update

You should now find that whenever you check out your project or do an SVN update it will update Rails as well. This is ok, but you’ll soon find you want a little more control over when you update to the latest version of Rails. To manually specify which revision of Rails you want use the -r flag:

svn propset svn:externals "rails -r4859" vendor
svn update

and just because Rails is meant to be easy, it ships with two Rake tasks to do this for you (though with the conundrum that you can only execute them if you’ve got a Rails project already created)

rake -T rails:freeze

To sync your project’s javascript and config files with the Rails that’s in your vendor directory execute the following rake command:

rake rails:update # Update both configs, scripts and public/javascripts from Rails
  • Thanks for this Tim, very useful. Especially about being able to rollback if edge is broken.

  • Pingback: » Blog Archive » site design - getting started()

  • Anonymous


  • Anonymous

    this page locks up my browser (Firefox, UNIVERSAL OS X) if javascript is enabled :(

  • Sters

    I think you shouldn’t set svn:externals on the vendor directory, only the rails subdirectory. Sometimes people have other stuff in there too.

  • Anon: Sorry, not sure what’s causing that. I’ll forward on your feedback onto the web guys.

    Sters: Not neccessarily. If you want more than one external defined in the vendor directory then you just separate each with a newline:

    svn propset svn:externals "rails
    redcloth" vendor

    Once you’ve got the grasp of using svn:externals you may also want to check out Piston, a tool that allows you to store the contents of the remote repository in your SVN and update it just as you would using straight svn:externals. Very handy.

  • dwormuth

    I think the string:

    svn propset svn:externals "rails vendor/rails" vendor 

    is malformed. I could only get it to work with the following:

    svn propset svn:externals "rails" vendor/rails

    I’m new to svn, is that correct, or did I do something bad?

  • dwormuth

    Trying this again:

    I think the string:

    <code>svn propset svn:externals “rails vendor/rails” vendor </code>

    is malformed. I could only get it to work with the following:

    <code>svn propset svn:externals “rails vendor/rails” vendor </code>

    I’m new to svn, is that correct, or did I do something bad?

  • dwormuth

    Grrrr, the second string should be:

    <code>svn propset svn:externals “rails” vendor/rails</code>

    PS, it would be nice to add a “preview” option to the posts :)

  • wilford brimley

    i can confirm that problem

    svn propset svn:externals "rails vendor/rails" vendor


    svn: Error parsing svn:externals property on 'vendor': 'rails vendor/rails
  • wilfordbrimley
    svn propset svn:externals "rails" vendor

    “the ‘rails’ in the beginning of the quoted string sets the directory”

  • wilfordbrimley


    it should read:

    svn propset svn:externals "rails" vendor

  • Sorry it took so long to edit this article. It should indeed read:

    svn propset svn:externals "rails" vendor

    For an updated technique on managing edge Rails you can check out my more recent article: A clean slate, Edge Rails recipe

  • stormville

    I am a windows user and this worked for me:
    rails cutting_edge_project
    cd cutting_edge_project
    svn co vendor/rails
    ruby vendor/rails/railties/bin/rails .
    ruby script/server

  • stormville: sure, that will work, as long as your project isn’t in SVN itself… otherwise you’re checking out the Rails repo in the middle of your own repo. It’s a good point though, doing ruby vendor/rails/railties/bin/rails . from your vendor directory… though it could leave some unnecessary folders lying around from the previous ver of rails.

  • Jabberwock

    A more user friendly method of setting svn:externals is:

    svn propedit svn:externals vendor/

    This will fire up whatever editor is stored in $SVN_EDITOR, where you can add your externals. Once you save and quit the editor, the new property values will be set.

  • Coward

    I’ve installed edge rails, but not seeing it being used. How is the vendor/rails path added? I’m using fast cgi. I have two rails directories, one with edge, and one without. They both display the same result with rails -v. I also added a ‘raise’ to to_xml, and it didn’t see it. I’m assuming rails -v will tell me the build number.

  • sukeerthi adiga

    Good one

    Thanks a lot

Get the latest in Front-end, once a week, for free.