Solved: git svn Broken in Mavericks

I used git to connect to my employer’s subversion server. I was using a package called git-svn which includes connectors between the two systems. Upon upgrading to the Mavericks, git svn stopped working. The solution follows.

Install Xcode

First, install the latest version of Xcode. An interesting note is that in the move from Lion to Mountain Lion, Apple decided to move it from its former home in /Developer/Xcode to /Applications/Xcode. This was the root source of many of the issues as many of the utilities were searching in the wrong place for the appropriate binaries.

Install Xcode Command Line Tools

Another change they’ve made is that the command line tools are no longer installed by default. Pre-Mountain Lion they were included with Xcode with no additional installation necessary. To install the command line tools, launch Xcode, open the Preferences, and switch to the Downloads tab:

Xcode Preferences

One of the entries there is Command Line Tools. Mine already says Installed as I’ve already installed it, but if you haven’t, it’ll appear as an Install button as the iOS 4.0 and 3.0 Device Debugging Support entries do in my screenshot above.

Link the svn Libraries

After this, you may be tempted to run a git svn command and see what happens. I received the following output:

$ git svn rebase
Can't locate SVN/Core.pm in @INC (@INC contains: /usr/local/Cellar/git/1.8.4/lib /Library/Perl/5.16/darwin-thread-multi-2level /Library/Perl/5.16 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.4 /System/Library/Perl/5.16/darwin-thread-multi-2level /System/Library/Perl/5.16 /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level/System/Library/Perl/Extras/5.16 .) at /usr/local/Cellar/git/1.8.4/libexec/git-core/git-svn line 41.

The problem here is that the git svn command requires Perl libraries that aren’t linked in Mavericks (or Mountain Lion). [1] So, we’ll have to manually link them. Run the following in your terminal to link the library:

$ sudo ln -s  /Applications/Xcode.app/Contents/Developer/Library/Perl/5.16/darwin-thread-multi-2level/SVN /System/Library/Perl/Extras/5.16/SVN

Now when you run git svn rebase you will likely be presented with a different error. This is good because it indicates progress! But obviously poor because it’s not working.

$ git svn rebase
Can't locate loadable object for module SVN::_Core in @INC (@INC contains: /usr/local/Cellar/git/1.8.4/lib /Library/Perl/5.16/darwin-thread-multi2level /Library/Perl/5.16 /Network/Library/Perl/5.16/darwin-thread-multi-2level /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.4 /System/Library/Perl/5.16/darwin-thread-multi-2level /System/Library/Perl/5.16 /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level /System/Library/Perl/Extras/5.16 .) at /System/Library/Perl/Extras/5.16/SVN/Base.pm line 59 BEGIN failed--compilation aborted at /System/Library/Perl/Extras/5.16/SVN/Core.pm line 5. Compilation failed in require at /usr/local/Cellar/git/1.8.4/libexec/git-core/git-svn line 41.

So now it appears it can find the Subversion core, but cannot find some other libraries it requires. Issue the following command to remedy this:

$ sudo ln -s /Applications/Xcode.app/Contents/Developer/Library/Perl/5.16/darwin-thread-multi-2level/auto/SVN/ /System/Library/Perl/Extras/5.16/auto/SVN

By doing this, we’ve now linked all of the Subversion Perl directories necessary for this command to run correctly.

You should follow me on twitter here.

Update 1 - March 19, 2012 I installed Mountain Lion DP2 over the weekend which broke this again. However, my exact instructions still applied and fixed the issue. I simply needed to install the latest version of Xcode 4.4 (available from developer.apple.com) and then run the commands listed above.

Update 2 - October 23, 2013 It appears this technique works on Mavericks as well as it appears Mavericks ships with a newer version of Perl. This article has been updated accordingly. Credit to @antonmoiseev for this discovery!

To use this on Mountain Lion, use the following 2 commands:

$ sudo ln -s  /Applications/Xcode.app/Contents/Developer/Library/Perl/5.12/darwin-thread-multi-2level/SVN /System/Library/Perl/Extras/5.12/SVN
$ sudo ln -s /Applications/Xcode.app/Contents/Developer/Library/Perl/5.12/darwin-thread-multi-2level/auto/SVN/ /System/Library/Perl/Extras/5.12/auto/SVN

1. Note, I am using the version of git from Homebrew. Your outcome may differ slightly if you are using a different version or not using Homebrew.

Published 19 Feb 2012

Scaling and leading engineering and data teams to solve the world's problems
Victor Quinn on Twitter