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

7

12

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.

Karlotte answered 6/5, 2020 at 14:2 Comment(2)
Try to install the module SVN::Core.Folk
Running into this same problem on Big Sur 11.4 - on M1 mac. Have installed git/svn/perl through brew. Tried installing SVN::Core through cpan but it fails due to being unable to find APR and APRUTILLarder
K
24

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).

Karlotte answered 6/5, 2020 at 14:12 Comment(3)
I don't really like this solution, but it works and that's more than I can say for every other solution I've found.Sinaloa
Life safer! Reminds me of years ago when I last had to use subversion (and thus resorted to git-svn) and had that same (?!) perl error due to missing module or some bug in git-svn script. Thanks. (Afternote: still needed the cpan Term::ReadKey command noted below by @Torello.)Isosteric
Updating the PERL5LIB env var worked for me. Seems better to try that before modifying git-svnCatinacation
W
9

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
Willem answered 22/7, 2021 at 15:55 Comment(1)
This worked for me as well. Note that my version number in the site_perl directory happened to be 5.18.4 and so I adjusted the library location accordingly.Observe
W
6

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
Weeds answered 11/10, 2020 at 14:17 Comment(0)
M
3

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.

Mall answered 8/4, 2021 at 0:17 Comment(0)
T
0

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.

Tricorn answered 13/6, 2021 at 16:59 Comment(0)
V
0

The error message says:

$ git svn --version
Can't locate SVN/Core.pm in @INC (you may need to install the SVN::Core module) (@INC contains: /usr/local/opt/subversion/lib/perl5 /usr/local/Cellar/git/2.31.1/share/perl5 /Applications/Xcode.app/Contents/Developer/Library/Perl/5.28/darwin-thread-multi-2level /Library/Developer/CommandLineTools/Library/Perl/5.28/darwin-thread-multi-2level /Library/Perl/5.30/darwin-thread-multi-2level /Library/Perl/5.30 /Network/Library/Perl/5.30/darwin-thread-multi-2level /Network/Library/Perl/5.30 /Library/Perl/Updates/5.30.2 /System/Library/Perl/5.30/darwin-thread-multi-2level /System/Library/Perl/5.30 /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level /System/Library/Perl/Extras/5.30) at /usr/local/Cellar/git/2.31.1/share/perl5/Git/SVN/Utils.pm line 6.
BEGIN failed--compilation aborted at /usr/local/Cellar/git/2.31.1/share/perl5/Git/SVN/Utils.pm line 6.
Compilation failed in require at /usr/local/Cellar/git/2.31.1/share/perl5/Git/SVN.pm line 25.
BEGIN failed--compilation aborted at /usr/local/Cellar/git/2.31.1/share/perl5/Git/SVN.pm line 32.
Compilation failed in require at /usr/local/Cellar/git/2.31.1/libexec/git-core/git-svn line 23.
BEGIN failed--compilation aborted at /usr/local/Cellar/git/2.31.1/libexec/git-core/git-svn line 23.

This is because git-svn is implemented by Perl, it needs a Perl library called SVN::Core to run。 Changing the first line of git-svn script from #!/usr/bin/perl to #!/usr/local/bin/perl won't fix this error!!! Because this just changes the Perl library from system default version to brew installed version。If the brew installed version doesn't contains SVN::Core, it'll still fail:

$ git svn --version
Can't locate SVN/Core.pm in @INC (you may need to install the SVN::Core module) (@INC contains: /usr/local/Cellar/git/2.31.1/share/perl5 /Applications/Xcode.app/Contents/Developer/Library/Perl/5.28/darwin-thread-multi-2level /Library/Developer/CommandLineTools/Library/Perl/5.28/darwin-thread-multi-2level /usr/local/Cellar/perl/5.34.0/lib/perl5/site_perl/5.34.0/darwin-thread-multi-2level /usr/local/Cellar/perl/5.34.0/lib/perl5/site_perl/5.34.0 /usr/local/Cellar/perl/5.34.0/lib/perl5/5.34.0/darwin-thread-multi-2level /usr/local/Cellar/perl/5.34.0/lib/perl5/5.34.0 /usr/local/lib/perl5/site_perl/5.34.0/darwin-thread-multi-2level /usr/local/lib/perl5/site_perl/5.34.0) at /usr/local/Cellar/git/2.31.1/share/perl5/Git/SVN/Utils.pm line 6.
BEGIN failed--compilation aborted at /usr/local/Cellar/git/2.31.1/share/perl5/Git/SVN/Utils.pm line 6.
Compilation failed in require at /usr/local/Cellar/git/2.31.1/share/perl5/Git/SVN.pm line 25.
BEGIN failed--compilation aborted at /usr/local/Cellar/git/2.31.1/share/perl5/Git/SVN.pm line 32.
Compilation failed in require at /usr/local/Cellar/git/2.31.1/libexec/git-core/git-svn line 23.
BEGIN failed--compilation aborted at /usr/local/Cellar/git/2.31.1/libexec/git-core/git-svn line 23.

Note that the Perl version has been changed, but the error still exists. Because there is no SVN:Core in the directories indicated by @INC.

Now some answers may tell you to install SVN::Core by cpan SVN::Core, Don't do that!!! This won't solve the problem! Because the version of SVN::Core it installed, may not match with your SVN version:

$ git svn --version
error: git-svn died of signal 11

By the way, cpan is rubbish, don't use it to install anything. It compiles the source before installation but cannot control the compile flags/options, and it cannot uninstall things that are installed by itself.


Here is the right solution:

The corresponding Perl libraries are already installed when you installed svn, and brew has already told you:

$ brew info svn
subversion: stable 1.14.1 (bottled), HEAD
Version control system designed to be a better CVS
https://subversion.apache.org/
/usr/local/Cellar/subversion/1.14.1_2 (234 files, 32.1MB) *
  Poured from bottle on 2021-06-02 at 15:52:30
From: https://mirrors.ustc.edu.cn/homebrew-core.git/Formula/subversion.rb
License: Apache-2.0
==> Dependencies
Build: openjdk ✘, pkg-config ✘, [email protected] ✔, scons ✘, swig ✘
Required: apr ✔, apr-util ✔, gettext ✔, lz4 ✔, [email protected] ✔, utf8proc ✔
==> Options
--HEAD
    Install HEAD version
==> Caveats
svntools have been installed to:
  /usr/local/opt/subversion/libexec

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

You may need to link the Java bindings into the Java Extensions folder:
  sudo mkdir -p /Library/Java/Extensions
  sudo ln -s /usr/local/lib/libsvnjavahl-1.dylib /Library/Java/Extensions/libsvnjavahl-1.dylib
==> Analytics
install: 33,749 (30 days), 67,978 (90 days), 239,148 (365 days)
install-on-request: 33,129 (30 days), 67,011 (90 days), 229,097 (365 days)
build-error: 0 (30 days)

We can see that the Perl bindings are located in /usr/local/opt/subversion/lib/perl5, we just need to let git-svn use this path. With a little investigation of git-svn script, we can see this behavior is controlled by an environment variable called GITPERLLIB:

$ head /usr/local/Cellar/git/2.31.1/libexec/git-core/git-svn
#!/usr/bin/perl

use lib (split(/:/, $ENV{GITPERLLIB} || '/usr/local/Cellar/git/2.31.1/share/perl5:/Applications/Xcode.app/Contents/Developer/Library/Perl/5.28/darwin-thread-multi-2level:/Library/Developer/CommandLineTools/Library/Perl/5.28/darwin-thread-multi-2level'));
# Copyright (C) 2006, Eric Wong <[email protected]>
# License: GPL v2 or later

So the right way to solve this problem is to add the following code to your bashrc or zshrc:

export GITPERLLIB=/usr/local/opt/subversion/lib/perl5/site_perl/$<your_perl_version>/darwin-thread-multi-2level

Problem solved!

Vargueno answered 6/1, 2023 at 4:53 Comment(0)
A
0

I ran into this issue too on OSX Ventura, and none of the other answers got me all the way there. First I made sure I installed subversion, git and git-svn via homebrew. Then I used the excellent answer from @guo-ang to export the GITPERLLIB path.

However, when I followed @guo-ang's answer, my error changed from complaining about a missing SNV/Core.pm to:

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

So instead of just adding the path to the subversion perl libraries, I also needed to add the path to the git perl libraries as well. So my final export included both paths separated by a :

export GITPERLLIB=/usr/local/opt/subversion/lib/perl5/site_perl/5.30.3/darwin-thread-multi-2level:/usr/local/opt/git/share/perl5

Note that the above version number in the path is specific to my installed version of subversion and will likely be different on your system.

After including both paths in the GITPERLLIB environment variable my git svn command ran successfully.

Agiotage answered 7/3, 2023 at 16:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.