Chronicling My Ruby on Rails Journey

Subversion 1.4.2 server and Using it from Rails and RadRails

Posted by: Bob Ngu on: April 10, 2007

My RoR efforts have culminated in JiggyMe, check it out!

Ok, so here I am, a Linux newbie, a Subversion newbie and more or less a RoR newbie as well trying to figure out how to setup and configure Subversion for use by Rails project from RadRails using Subclipse. This is in preparation for migrating my Rails apps to Slicehost in the future, I had no idea what was in store for me.

Anyway, I am writing down all the newbie steps I remember and if it helps someone else, great. Note that this is from the perspective of a Linux and Subversion newbie…

First off, my Win XP environment is setup with the following

  • RadRails 0.7.2 with Subclipse plugin for access to Subversion
  • Ruby on Rails installed with MySQL and using Webrick for development

My Linux environment is as such

  • Fedora Core 6 on VMWare Server 1.0.2
  • Subversion 1.4.2 on FC6.

Some basic things about Subversion (SVN):

  • SVN runs on port 3690, so make sure your firewall is configured to allow access
  • to show svn server version “svnserve –version”, for svn client, “svn –version”
  • svn can be accessed remotely using Apache, svnserve, sshd over svnserve (Chapter 6 of Subversion manual). I am using the sshd over svnserve method
  • to run SVN server, run “svnserve -d”, you can restrict access with path like “svnserve -d -r /home/svn/repository” and you can access your project using “svn:///project1″. You can also run SVN using inetd, for those instructions, read the manual
  • to list repository contents, “svn list file:///home/svn/repository/trunk”
  • there isn’t a way to gracefully shutdown svnserve, just do “ps -e | grep svn”, find the process id, and kill it

Now the install steps on FC6:

  1. Install subversion server: “yum install subversion”
  2. Create 2 SVN users, “adduser svn”, and “adduser user1″
  3. Add passwords both SVN users, “passwd svn”, and “passwd user1″
  4. Add user1 to svn group, and set rwx permissions for svn group to repository “chmod -R g+rwx *” recursive starting with svn directory.
  5. Create a new repository using svn account “svnadmin create /home/svn/repository”
  6. Create a basic directory structure for the repository. I use the recommended three top level directories: branches, tags and trunk. I work out of trunk and create branches when I have stable builds. Create this structure in a temporary directory (created below) and then import it into the new repository.

    mkdir ~/temp
    mkdir ~/temp/branches
    mkdir ~/temp/tags
    mkdir ~/temp/trunk

    Do the initial import of this structure. Note that the location of the repository must be explicitly stated—you can’t use ~/. Of course, all ~/ means is /users/your_user_name. Once you’re done, you can trash that temporary directory you created (be careful with that rm command!).

    svn import ~/temp file:///home/svn/repository/ -m “initial import”
    rm -r ~/temp

  7. NOTE: I have decided to use repository structure with branches, tags, and trunk at the root and project name underneath. There are other ways to structure your repository but this is a fairly common structure.

Now, to get RadRails to talk to SVN (all steps on Win XP machine):

  1. to get RadRails to talk to ssh, under Windows –> Preferences –> Team –> SVN –> SVN interface: make sure you have selected JavaSVN.
  2. from within RadRails, add a new repository, follow the instructions here
  3. from RadRails, right click on your project…Team…share project, select SVN, use existing repository from above, use project name as folder name. When I did this initially, RadRails gave an error while trying to import the project “malformed network error”. Follow the instructions here to fix the problem.
  4. You should ignore log files and tmp files from svn, see here and here for more details

Phew, now you should be all set, good luck!

Leave a Reply