Greg
Greg

Reputation: 1402

git: svn is not a git command - Mac

I had no issues yesterday but today I cannot run git svn anymore. It says:

git: 'svn' is not a git command. See 'git --help'.

The most similar commands are
    fsck
    mv
    show

I don't know if it's relevant but since yesterday I updated npm(6.14.4) and node (v12.6.0).

I'm on macOs Catalina

Upvotes: 15

Views: 11879

Answers (5)

jqgsninimo
jqgsninimo

Reputation: 7038

Thanks to BitByteDog for his answer.

I encountered this problem again under the macOS Ventura v13.1, and solved the problem by installing git-svn.

brew install git-svn

Below is the original answer.


I found a simple fixed solution for macOS Big Sur v11.1 (20C69) on GitHub.

  1. make sure install git, svn, perl with brew.

    brew install git
    brew install perl
    brew install subversion
    
  2. edit /usr/local/Cellar/git/2.30.0/libexec/git-core/git-svn.

    replace #!/usr/bin/perl with #!/usr/local/bin/perl

  3. git svn works.


The above solution only works under perl 5.32.0.

When I updated the perl to 5.32.1, git svn can no longer work.

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

I found a solution on GitHub.

Now subversion built with system perl, so we can add an environment variable to solve this problem:

export PERL5LIB=/usr/local/lib/perl5/site_perl/#{perl_version}/darwin-thread-multi-2level

You should replace #{perl_version} with system perl's version.

For macOS Big Sur:

export PERL5LIB=/usr/local/lib/perl5/site_perl/5.28.2/darwin-thread-multi-2level

Upvotes: 12

BitByteDog
BitByteDog

Reputation: 3484

On Monterey, it was just:

brew install git-svn

Upvotes: 2

situee
situee

Reputation: 2740

  1. First install git and svn with brew
brew install git
brew install svn
  1. Use system default perl at /usr/bin/perl

if you installed perl with brew, please uninstall it.

brew uninstall perl

use which perl to check if using the system default perl at /usr/bin/perl. Make sure the git-svn use the #!/usr/bin/perl use following command to check which perl is git-svn using

$ head -1 $(brew --prefix)/opt/git/libexec/git-core/git-svn
#!/usr/bin/perl
  1. check you svn's perl version at /usr/local/Cellar/subversion/1.14.1/lib/perl5/site_perl/5.18.4

  2. If you got error Can't locate SVN/Core.pm in @INC you also need to set PERL5LIB path, for Catalina:

export PERL5LIB=/usr/local/lib/perl5/site_perl/5.18.4/darwin-thread-multi-2level

for Big Sur:

export PERL5LIB=/usr/local/lib/perl5/site_perl/5.28.2/darwin-thread-multi-2level

Reference: https://github.com/Homebrew/homebrew-core/issues/52490

Upvotes: 4

Jeppe Gravgaard
Jeppe Gravgaard

Reputation: 63

I ran into the same problem after upgrading macOS from version 10.15 (Catalina) to 10.15 (Big Sur).

Thank you very much for your answer jqgsninimo. Those 3 steps took me 99% of the way. But then I got the error

Can't locate SVN/Core.pm in @INC (you may need to install the SVN::Core module) (@INC contains: /usr/local/Cellar/git/2.30.0/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.28/darwin-thread-multi-2level /Library/Perl/5.28 /Network/Library/Perl/5.28/darwin-thread-multi-2level /Network/Library/Perl/5.28 /Library/Perl/Updates/5.28.2 /System/Library/Perl/5.28/darwin-thread-multi-2level /System/Library/Perl/5.28 /System/Library/Perl/Extras/5.28/darwin-thread-multi-2level /System/Library/Perl/Extras/5.28) at /usr/local/Cellar/git/2.30.0/share/perl5/Git/SVN/Utils.pm line 6. BEGIN failed--compilation aborted at /usr/local/Cellar/git/2.30.0/share/perl5/Git/SVN/Utils.pm line 6. Compilation failed in require at /usr/local/Cellar/git/2.30.0/share/perl5/Git/SVN.pm line 25. BEGIN failed--compilation aborted at /usr/local/Cellar/git/2.30.0/share/perl5/Git/SVN.pm line 32. Compilation failed in require at /usr/local/Cellar/git/2.30.0/libexec/git-core/git-svn line 23. BEGIN failed--compilation aborted at /usr/local/Cellar/git/2.30.0/libexec/git-core/git-svn line 23.

If anyone else experiences the same problem, the solution for me was to run this command

export PERL5LIB=/usr/local/lib/perl5/site_perl/5.28.2/darwin-thread-multi-2level

I found the commands from this GitHub answer

Upvotes: 2

deepdivedylan
deepdivedylan

Reputation: 359

UPDATE: SEPTEMBER 2020

It seems the end is here. Following the original suggestion will delete subversion forever. I found a verified version of Subversion for MacOS and downloaded and installed it. I then needed to add Subversion to the $PATH variable to supersede Apple's svn (which just prints a message saying subversion is no longer included). To add it, add this line to your ~/.zprofile:

export PATH=/opt/subversion/bin:$PATH

This will fix svn. I still have not figured out how to fix git svn.

NB: I also am aware that one can get subversion from homebrew, but homebrew is prohibited by my company's policies. If homebrew works better for somebody, please post your results here.

ORIGINAL ANSWER: MARCH 2020

Same thing happened to me today. After software update, git svn and svn are gone. It seems that Apple is deprecating Subversion in XCode:

Command line tool support for Subversion — including svn, git-svn, and related commands — is no longer provided by Xcode. If you need Subversion or related command line tools, install the Command Line Tools package by running xcode-select --install. (50266910)

In the mean time, I was able to resolve this situation by deleting the XCode command line tools and reinstalling them:

sudo rm -Rf /Library/Developer/CommandLineTools
sudo xcode-select --install

After that, git svn and svn were back. Hopefully that will give us a stay of execution before final deprecation and deletion.

Upvotes: 6

Related Questions