git-svn Can't locate SVN/Core.pm after fresh installation of macOS Catalina 10.15.4

Viewed 7667

Recently I reinstalled macOS Catalina 10.15.4. After I installed Command_Line_Tools_11.4.1, it told me svn is no longer working with Xcode. Then I installed both git and svn by brew, hopefully git-svn would work. Unfortunately got this error message:

Can't locate SVN/Core.pm in @INC (you may need to install the SVN::Core module) (@INC contains: /usr/local/Cellar/git/2.26.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 /Library/Perl/5.18/darwin-thread-multi-2level /Library/Perl/5.18 /Network/Library/Perl/5.18/darwin-thread-multi-2level /Network/Library/Perl/5.18 /Library/Perl/Updates/5.18.4 /System/Library/Perl/5.18/darwin-thread-multi-2level /System/Library/Perl/5.18 /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level /System/Library/Perl/Extras/5.18 .) at /usr/local/Cellar/git/2.26.2/share/perl5/Git/SVN/Utils.pm line 6.

Both git & svn are the latest version.

Please help me out.

5 Answers

Finally I figure it out!!!

Open the git-svn file (perl script, in my case file location is /usr/local/opt/git/libexec/git-core/git-svn), change the first line #!/usr/bin/perl to #!/usr/local/bin/perl

And it works!

I guess system perl doesn't include perl SVN/Core, but brew perl has it (dependency of brew svn).

Solution for MacOS Big Sur 11.5

After struggling with this error for hours:

Can't locate SVN/Core.pm in @INC (you may need to install the SVN::Core module)

I've finally found a solution that actually works.

If you run:

brew reinstall subversion

It will print a message like this:

The perl bindings are located in various subdirectories of:
  /usr/local/opt/subversion/lib/perl5

Then you just need to run this command before using git svn to load the SVN module from the correct path:

export PERL5LIB=/usr/local/opt/subversion/lib/perl5/site_perl/5.30.2/darwin-thread-multi-2level

Solution for those, who, like me - want to use Sourcetree client on macOS Catalina with git-svn:

First step:

brew install git
brew install perl
brew install subversion

edit
/usr/local/Cellar/git/git_version/libexec/git-core/git-svn
replace
#!/usr/bin/perl
with
#!/usr/local/bin/perl

Second step, install missed perl modules:

cpan SVN::Core
cpan Term::ReadKey

Third step, configure SourceTree:

In Sourcetree->Preferences - set option "use system git", from:

/usr/local/Cellar/git/git_version/git

While not a permanent fix, a workaround is to set ${GITPERLLIB}:

$ export GITPERLLIB=/usr/local/Cellar/git/2.31.1/share/perl5:/usr/local/lib/perl5/site_perl/5.28.2/darwin-thread-multi-2level
$ git svn clone svn+ssh://...

worked for me without editing any scripts installed by brew.

Ensure you've installed Perl, Subversion and dependencies via Homebrew:

brew install perl subversion apr apr-util

Install required Perl modules into ~/perl5:

export PATH="/usr/local/opt/apr/bin:/usr/local/opt/apr-util/bin:$PATH"
PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" cpan local::lib Git::SVN SVN::Core

Verify installed modules by:

PERL5LIB="$HOME/perl5" cpan -l | grep SVN

Then configure Perl as following (based on brew info perl steps):

eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)"

Finally run Git's SVN:

PERLLIB="$HOME/perl5" git svn clone https://svn.somecode.example.com/svn/trunk

If you're still stuck, try GitHub and GitLab websites which offer migration with a Git/SVN.

E.g. in GitHub, create a new repository, then import the project by pasting old repository’s clone URL.

Related