Building Subversion (SVN) on Mac OS X
Whether you’re a software developer, writer, graphic designer, or project manager, if you create files that change over time, you’ll eventually realize that you need some help keeping track of the changes and keeping your data backed-up and synchronized. This becomes even more important if you share these files with other people who are also making changes to them. Fortunately, there’s software to help us do exactly this.
This article walks you through installing Subversion (also called “SVN”) on Mac OS X. Subversion is a free/open-source version control system. It remembers every change ever made to the files and directories in your projects. This allows you to recover older versions of your data, or examine the history of how your data changed. You can read more about SVN in the online Subversion book.
Rolling Your Own
While Metissian’s pre-built binaries for OS X work well (and actually install into
/usr/local just like they should), you might be the type, like me, who still wants to build the install of SVN yourself (just like you did for Ruby on Rails, right?).
Fortunately, building SVN on Mac OS X is a piece of cake.
Note: Although these are “Mac OS X specific instructions,” they should work just fine on other UNIX-type systems (like Linux) without modification.
Set Your Path
If you’ve followed along with my other tutorials you already know why it’s important to install things into the
/usr/local folder (here’s why). You then need to tell the system to always look for command-line programs there first. If you’ve already run through this, you can feel free to skip this step. Otherwise, keep reading.
To see if the path has been set properly, we can check the contents of the
.bash_login file (a special, hidden file in the root of our home folder) for a
PATH line using a text editor. TextMate, TextWrangler, BBEdit, and if you’re a real geek – vi – are all perfectly good options.
To open or create the file with TextMate, for example, open Terminal.app (in
/Applications/Utilities) and type:
This will open the file if it already exists, or create a blank file if it doesn’t. In either case, add the following line at the very end of the file:
Now save and close the file.
It’s critical that
/usr/local/sbin come first in the path. Just having them in the path isn’t enough. They have to be first.
To make sure the changes are picked up correctly, we now need to execute the file with the following command in Terminal.app:
It’s likely there will be no response from the shell here, just the prompt, but that’s OK, the changes have been picked up and we’re ready to move on.
We’re going to download the latest Subversion into a folder on the Desktop, unpack it, compile it, and install it. To do this, you’ll need to run the
sudo command, which allows you to run administrative commands. When prompted, just enter your password to continue (this is the command-line equivalent of an OS X package installer asking you for your password).
Cautionary Note: Recently, a new version of Subversion was released, offering some updated features and enhancements, but lacking compatibility with older repositories. So, if you’re not sure what version of Subversion the repositories you’ll be connecting to are using, it’s best to stick with the 1.3 branch. If you’re lucky enough to control your own repositories or know for sure that they have been migrated to the newer 1.4 branch, go with the newer version.
If you want to install version 1.3 now and 1.4 later, that’s no problem. Just run through the second set of instructions when you’re ready, and you’ll be in business.
To install the 1.3.x Subversion branch, enter these commands in Terminal.app, one after the other:
curl -O http://subversion.tigris.org/downloads/subversion-1.3.2.tar.gz tar xzvf subversion-1.3.2.tar.gz cd subversion-1.3.2 ./configure --prefix=/usr/local --with-openssl --with-ssl --with-zlib make sudo make install cd ..
Or, to install the 1.4.x Subversion branch, run through these steps:
curl -O http://subversion.tigris.org/downloads/subversion-1.4.3.tar.gz curl -O http://subversion.tigris.org/downloads/subversion-deps-1.4.3.tar.gz tar xzvf subversion-1.4.3.tar.gz tar xzvf subversion-deps-1.4.3.tar.gz cd subversion-1.4.3 ./configure --prefix=/usr/local --with-openssl --with-ssl --with-zlib make sudo make install cd ..
You may see a warning about “missing” Berkeley DB. Just ignore it! This is actually a good thing, because we’ll want to always use SVN’s superb FSFS repository format rather than Berkeley DB.
You can then close Terminal.app and, if you’d like, drag the
src folder that’s now on your Desktop into the Trash.
That’s it, you’re done.
So you’ve got Subversion … now what? For more information on actually using SVN, there are a few good starting points:
- Version Control with Subversion
- How to Use Rails with Subversion
- The Subversion FAQ
- Top Ten Subversion Tips for CVS Users
Good luck, and happy source-controlling.