views:

849

answers:

4

First a bit of background.

I have been working on the MS platform for my entire development career. Up until 2 weeks ago, I had never booted any other OS than 98/XP/Vista. I started using VSS long long ago, and made the change to SVN about 2 years ago. With SVN I use TortiseSVN and use the standard branch/tag/trunk setup.

My projects are also self contained, meaning I can go to a fresh dev box, pull down a single repository, open VS, press F5 and it will run (most of the time). All dependencies are stored in a lib folder, source code is in a src folder, etc...

In an effort to learn new things, I've decided to build a Ruby on Rails application and have created a Ubuntu based development machine. I have a SVN server up and running and am working with another person on this project. He happens to be using a Mac for his development machine.

And now for the issues.

I seem to be struggling with how to manage the various versions of ruby, rails and all of the plugin's I'm working with. I also seem to be struggling with using SVN on Ubuntu.

So Ubuntu comes with Ruby pre-installed. I want to say it's version 1.8.5. Either way, I had a bunch of gems to install for the plugin I'm using (Community Engine). Being new to *nix, I didn't use sudo when installing them and ran into all sorts of issues. I ended up blowing away Ruby completely and starting fresh. That seemed to work.

The problem is though, that after I commit my code, and the other guy gets latest, he has to go through the whole process of installing gems.

What is the best practice for managing gems and plug-ins in a RoR application? I don't care if a zillion files get added to SVN. Diskspace and network bandwidth are cheap. I just don't know how to do this correctly.

So on to SVN.

I have installed RapidSVN, but very frequently run into issues with folders getting locked. A couple times I realized my mistake, others, I had no clue why. But in both scenarios, i couldn't fix it. I ended up making a backup of my code, pulling down a new working copy, then manually moving over changes and being a bit smarter when committing them to the project.

I actually RTFM a bit last night and found that I'm supposed to create a bookmark for my repos, then do a "checkout working copy" from that bookmark. I'm not sure why, but ok, that's what the manual says...

What are some best practices for using SVN on a RoR project on Ubuntu?

I'm literally looking for a step by step process on this one.

edit I forgot to mention, I use NetBeans for my IDE, although i have not looked to see what kind of SVN support it has, if any. I looked at RubyMine, and would love to use it, but it appears to be too unstable right now.

+1  A: 

Many people use piston or desert to manage plugins and install gems into Rail local vendor folder (stored under SVN).

http://www.rubyinside.com/advent2006/12-piston.html http://pivotallabs.com/users/brian/blog/articles/459-build-your-own-rails-plugin-platform-with-desert

I also recommend using geminstaller which will help you both install all the same gems and the same versions of them

http://geminstaller.rubyforge.org/

I use SVN from the command line but if you were more comfortable with TortiseSVN you might want to try IDEs that have SVN nicely integrated like RadRails and NetBeans. The IDEs have very similar graphical SVN managers similar to Tortise, if you want to work on the cmd line just find a simple 10 minute SVN tutorial and you should be good to go.

I have never heard of rapid SVN and the normal SVN tool has always worked just find with me, hardly ever causing the locking folders issue.

danmayer
+4  A: 

For plugins, I'd personally recommend just sticking them in the vendor folder and add them to SVN as if you'd written the code yourself. Piston was also a great solution, but switched away from it when all the common plugins started moving to github (piston has been unreliable since then)

For gems, hopefully you're using rails 2 or higher. You should be listing the gems you require in your config/environment.rb using config.gem. Here's a bunch of information about that feature

What this means is that if you add a new gem, the next time your co-worker updates, his rails app won't boot until he's got the neccessary gems. He can then install them in one step using sudo rake gems:install

You can take this one step further, and put your gems in the vendor directory. This is commonly known as "vendor everything." The easiest way to do this is to list all the gems you use in environment.rb as above, and then run rake gems:unpack. There are 2 problems with this approach however, so I prefer not to use it myself.

  1. If you have 10 apps and they each vendor their gems, you end up keeping 10 copies of common gems in subversion, which makes updating all your sites a whole lot slower.
    This may not be an issue for you, or may be worth putting up with, it's just a personal preference.

  2. Some gems (such as mongrel or hpricot) have native extensions written in C. What this means is that when you install them, the .c source code is downloaded, and gcc gets run to compile it specifically for your system.
    If you installed a native C extension on ubuntu, then put it in the vendor folder, and later on tried to run that on OS X (or even possibly a different version of ubuntu) it would most likely crash your ruby process and bring your app down.
    If all your gems are pure-ruby ones, then this is not a problem, but it's just something to be aware of.

Orion Edwards
I like this approach. Why can't gems be in the vendor folder too? I seem to recall seeing the rails gem in there on a screen cast i saw. I cold be mistaken though.
levi rosol
Updated answer to explain :-)
Orion Edwards
awesome, and thanks for the complete answer. How will i know what gems have native C extensions? I assume i just need to look at the code for them. I'm ok with the dev having to update mongrel and hpricot themselves (we're using both of those) as they are less likely to change from what i see.
levi rosol
A: 

Orion mentioned having to rebuild gems that have been vendored when sharing them between different OS's - you can use the gems:build rake task to rebuild them automatically.

Jon Wood
A: 

First, figure out svn from the command line. The svn-book is on line. It's not too hard to do svn status or svn commit -m "blah". Most problems come if you use OS functions to delete or rename files. Use the svn commands for that.

Next, if rapidsvn is not working out for you, try svn-workbench. Hate to say it, but none of the linux svn GUI tools that I have seen are as good as tortoisesvn.

Plugins and svn are an issue. There is a tool called piston that aims to clear that up, though I don't use it. I check out the plugins into my vendor/plugins directory. If a new version comes out that I really want, I use my trusty update_plugin bash script to update the plugin:

#!/bin/bash

#  reinstall the plugin in an svn friendly way
plugin="some_plugin"
plugin_url="http://some_server/some_plugin/trunk"

for f in site1 site2 site3
do
  echo $f
  cd ~/rails/$f

  svn delete vendor/plugins/$plugin
  rm -rf vendor/plugins/$plugin
  svn -m "remove $plugin" commit
  script/plugin install $plugin_url
  svn add vendor/plugins/$plugin
  svn -m "add $plugin" commit

done