Skip to content

Instantly share code, notes, and snippets.

@KageKirin
Last active April 25, 2021 15:38
Show Gist options
  • Save KageKirin/87d71b10c115fd7c10a957c056051ac0 to your computer and use it in GitHub Desktop.
Save KageKirin/87d71b10c115fd7c10a957c056051ac0 to your computer and use it in GitHub Desktop.
Fix svn-git install

git-svn installation fix

Quick guide (and personal memo) on how to get git-svn to run on macOS with brew.

Issue

git-svn is written in perl and running on the perl5 binary bundled with git.
The issue is: the Perl module "SVN::Core" cannot be found. (Obviously, it hasn't be installed).

The error message looks like this:

Can't locate SVN/Core.pm in @INC

The solution is straightforward: provide the installation path of SVN::Core to git-svn.

Solution steps

  1. make sure you are using homebrew git. if not: brew install git
  2. make sure you have homebrew svn. if not: brew install subversion
    subversion has it's Perl bindings bundled, so we just need to inform git-svn about them.
  3. find the path to subversion's Perl bindings. it should be around /usr/local/Cellar/subversion/1.14.1/lib/perl5/site_perl/5.18.4/darwin-thread-multi-2level/ (YMMV on the svn version)
  4. open /usr/local/Cellar/git/2.30.2/libexec/git-core/git-svn (YMMV on the git version) in a text editor.
    the first line below the shebang, beginning with use lib is the one we need to change:
#!/usr/bin/perl

use lib (split(/:/, $ENV{GITPERLLIB} || '/usr/local/Cellar/git/2.30.2/share/perl5:/Applications/Xcode.app/Contents/Developer/Library/Perl/5.18/darwin-thread-multi-2level:/Library/Developer/CommandLineTools/Library/Perl/5.18/darwin-thread-multi-2level'));
  1. insert the path to the svn Perl module after the first path here:
    i.e. after /usr/local/Cellar/git/2.30.2/share/perl5,
    insert /usr/local/Cellar/subversion/1.14.1/lib/perl5/site_perl/5.18.4/darwin-thread-multi-2level/ (separate paths using colons :).
    the code should now read:
#!/usr/bin/perl

use lib (split(/:/, $ENV{GITPERLLIB} || '/usr/local/Cellar/git/2.30.2/share/perl5:/usr/local/Cellar/subversion/1.14.1/lib/perl5/site_perl/5.18.4/darwin-thread-multi-2level/:/usr/local/Cellar/perl/5.32.1_1/lib/perl5/site_perl/5.32.1/darwin-thread-multi-2level/:/Applications/Xcode.app/Contents/Developer/Library/Perl/5.18/darwin-thread-multi-2level:/Library/Developer/CommandLineTools/Library/Perl/5.18/darwin-thread-multi-2level'));
  1. git svn help and all others commands should work now.
@geyang
Copy link

geyang commented Apr 25, 2021

thanks a lot, this really helped!! Can't believe it is this easy!

@KageKirin
Copy link
Author

oh, that's nice to hear. You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment