You’re reading Hivelogic, a website about discovering quality, living more efficiently, and leading a simpler, more mindful life. This site was established in 2000 by Dan Benjamin, a writer, software developer, broadcaster, and usability geek (read more).


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:

mate ~/.bash_login

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:

export PATH="/usr/local/bin:/usr/local/sbin:$PATH" 

Now save and close the file.

It’s critical that /usr/local/bin and /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:

. ~/.bash_login

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.

Build It

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.

What Now?

So you’ve got Subversion … now what? For more information on actually using SVN, there are a few good starting points:

Good luck, and happy source-controlling.


matth

21 January 2008 at 4:51 am

Nice one, this seemed to fix the below error on OS X:

svn: This client is too old to work with working copy

_rs

29 January 2008 at 9:42 am

I’ve got an error for you ...

myusername:subversion-1.4.3 myuser$ ./configure—prefix=/usr/local—with-openssl—with-ssl—with-zlib
configure: Configuring Subversion 1.4.3
configure: creating config.nice
checking for gcc… no
checking for cc… no
checking for cc… no
checking for cl… no
configure: error: no acceptable C compiler found in $PATH
See `config.log’ for more details.
myusername:subversion-1.4.3 myuser$

—-

no acceptable C compiler found in $PATH ... hmmm, any ideas?

David Weiss

28 February 2008 at 4:52 pm

These directions for 1.4.3 do not seem to work with Mac OS X 10.5.2 on my MacBook. The make command fails with these comments:

sendrecv.c:965:2: error: #error APR has detected sendfile on your system, but nobody has written a
sendrecv.c:966:2: error: #error version of it for APR yet. To get past this, either write apr_sendfile
sendrecv.c:967:2: error: #error or change APR_HAS_SENDFILE in apr.h to 0.
make[3]: *** [sendrecv.lo] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [external-all] Error 1

Mat Harvard

04 March 2008 at 10:06 pm

@David, or anyone experiencing a similar problem while running the `make` command. I’ve ran into the same problem on both my iMac and MacBook.  Just open up the file `apr.h` in a text editor (not sure of the location, search for it and you’ll find it).  Look for the line that reads `#define APR_HAS_SENDFILE 1` (in SVN 1.4.6 it’s on line #220) and change it to `#define APR_HAS_SENDFILE 0`.  Run `make` again and everything should compile just fine.  Hope this helps.

Daniela van der Heijden

10 March 2008 at 4:15 am

Am also on OS X 10.5.2. on a MacBook same error as David and followed Mat’s suggestion:

sendrecv.c:965:2: error: #error APR has detected sendfile on your system, but nobody has written a
sendrecv.c:966:2: error: #error version of it for APR yet. To get past this, either write apr_sendfile
sendrecv.c:967:2: error: #error or change APR_HAS_SENDFILE in apr.h to 0.
make[3]: *** [sendrecv.lo] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [external-all] Error 1

what am I supposed to do?
Thanks
Daniela

Alderete

12 March 2008 at 1:25 pm

The location of the file that needs to be changed is ‘.../src/subversion-1.4.6/apr/include/apr.h’.

I recommend doing a “make clean” before you re-try running make, once you’ve made the change. Otherwise, Mat’s suggestion worked perfectly for me.

[...] things first: references. Couldn’t have done any of this without this article from Hivelogic and this one from Apple. The Hivelogic article is the one that got me started. In fact, [...]

Matt Gregory

24 March 2008 at 5:51 pm

I’m surprised nobody else has reported this error.  I got a “wrong architecture” error in the Console when starting the Web Sharing service after building and installing Subversion 1.4.6.  I’ve documented my solution (I use the term loosely) here :

http://dothemash.com/zerodiggs/2008/03/24/building-subversion-on-mac-os-x-105/

But, to summarize, some compiler options needed to be added so that the mod_dav_svn.so would contain the correct architectures for my iMac.

env CFLAGS=”-O -g -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch ppc64 -arch i386 -arch x86_64”
  LDFLAGS=”-arch ppc -arch ppc64 -arch i386 -arch x86_64”  ./configure—prefix=/usr/local—with-openssl—with-ssl—with-zlib

Thanks,
matt.

Federico

31 March 2008 at 6:39 pm

I was having the same problem with the apr.h file, and resolved it , but now I am getting the following error when I run sudo make install:

libtool: link: `strings/*.lo’ is not a valid libtool object
make[1]: *** [libapr-0.la] Error 1
make: *** [external-install] Error 1

I installed the 1.3 branch

Grant

12 April 2008 at 2:24 pm

I’m getting the same error as Federico. Has anyone figured this out yet?

Riz

23 April 2008 at 10:17 pm

I too am having the same problem as Federico and Grant after typing in sudo make install.

Also, at the end of the make command, I received the following erros:

sendrecv.c:965:2: error: #error APR has detected sendfile on your system, but nobody has written a
sendrecv.c:966:2: error: #error version of it for APR yet. To get past this, either write apr_sendfile
sendrecv.c:967:2: error: #error or change APR_HAS_SENDFILE in apr.h to 0.
make[3]: *** [sendrecv.lo] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [external-all] Error 1

I copied the part of the results where the error started. Hope that helps with figuring out a resolution. I wish I was more familiar with the error codes to be of more help.

Riz

24 April 2008 at 6:53 am

Just read the fix stated a few posts previously and it worked flawlessly! Thanks!

ada

07 May 2008 at 1:11 pm

hello all,
I was having the following problem before I tried to do the steps you outlined and I’m still having running into it:
ok here it goes:
i just got a new macbook pro and my development environment consists of eclipse europa and svn (and some other crap) lol
Whenever I check in a project from the svn repository, it checks it in, however when I go to WOLips view just the name is checked in, not the src files or anything else that that project has.  So when I go to click that little triange on the side there’s no dropdown files.  I don’t know what to do, has anyone run into this problem before, does anyne know what I’m doing wrong?  Any suggestions would be greatly appreciated!  Thank you in advance,