Homebrewでインストールした git svn で Can't locate SVN/Core.pm となるのを解決する

###[サクッと解決したい](https://qiita.com/chakiralu/items/7ba74859f6e338b58b15 "サクッと解決！")

# 動作環境
```
macOS Big Sur バージョン 11.4
MacBook Pro(2016)
プロセッサ 2.9 GHz デュアルコアIntel Core i5
メモリ 16 GB
```

# brew, git, subversion, perlのインストール状況
- brew

```
$ which brew
/usr/local/bin/brew

$ brew --version
Homebrew 3.1.12-75-ge71a0ed
Homebrew/homebrew-core (git revision 338328ef72; last commit 2021-06-17)
Homebrew/homebrew-cask (git revision 4eea6257b9; last commit 2021-06-16)
```

- git

```
$ which git
/usr/local/bin/git

$ brew info git
git: stable 2.32.0 (bottled), HEAD
Distributed revision control system
https://git-scm.com
/usr/local/Cellar/git/2.32.0 (1,517 files, 42.0MB) *
  Poured from bottle on 2021-06-10 at 10:02:58
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/git.rb
License: GPL-2.0-only
...省略...
```

- subversion

```
$ which svn
/usr/local/bin/svn

$ brew info subversion
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-05-23 at 13:33:41
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/subversion.rb
License: Apache-2.0
...省略...
The perl bindings are located in various subdirectories of:
  /usr/local/opt/subversion/lib/perl5
...省略...
```

- `/usr/local/opt/subversion/lib/perl5`にperl関連のモジュールがあるのかもしれない？

- perl

```
$ which perl
/usr/bin/perl

$ brew info perl
perl: stable 5.34.0 (bottled), HEAD
Highly capable, feature-rich programming language
https://www.perl.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/perl.rb
License: Artistic-1.0-Perl or GPL-1.0-or-later
...省略...
```

- brew版のperlはインストールしていない。

# 調査開始

- `git svn --version`すると`Can't locate SVN/Core.pm`と表示される。

```
$ 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 /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.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.
```

- 現在の`/usr/local/Cellar/git/2.31.1/share/perl5`ディレクトリ

```
$ ls -l /usr/local/Cellar/git/2.31.1/share/perl5
drwxr-xr-x  FromCPAN/
drwxr-xr-x  Git/
-rw-r--r--  Git.pm
drwxr-xr-x  Net/
```

- `/usr/local/Cellar/git/2.31.1/share/perl5/SVN/Core.pm`があれば動きそうなので`SVN/Core.pm`を探してシンボリックリンクを作成する。

- `Core.pm`の場所を探す。

```
$ find -L /usr -name 'Core.pm' | grep '/usr/local/opt/subversion/lib/perl5'
find: /usr/sbin/authserver: Permission denied
find: /usr/lib/cron/tabs: Permission denied
/usr/local/opt/subversion/lib/perl5/site_perl/5.28.2/darwin-thread-multi-2level/SVN/Core.pm
find: /usr/lib/cron/tmp: Permission denied
```

- `/usr/local/opt/subversion/lib/perl5/site_perl/5.28.2/darwin-thread-multi-2level/SVN`のシンボリックリンクを`/usr/local/Cellar/git/2.31.1/share/perl5`に作成する。

```
ln -sf \
    /usr/local/opt/subversion/lib/perl5/site_perl/5.28.2/darwin-thread-multi-2level/SVN \
    /usr/local/Cellar/git/2.31.1/share/perl5
```

- ここで`git svn --version`すると`Can't locate loadable object for module SVN::_Core`と表示される。`Can't locate SVN/Core.pm`は表示されなくなった。

```
$ git svn --version
Can't locate loadable object for module SVN::_Core in @INC (@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 /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.31.1/share/perl5/SVN/Base.pm line 59.
BEGIN failed--compilation aborted at /usr/local/Cellar/git/2.31.1/share/perl5/SVN/Core.pm line 5.
Compilation failed in require 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.
```

- `_Core`の場所を探す。

```
$ find -L /usr -name '_Core' | grep '/usr/local/opt/subversion/lib/perl5'
find: /usr/sbin/authserver: Permission denied
find: /usr/lib/cron/tabs: Permission denied
/usr/local/opt/subversion/lib/perl5/site_perl/5.28.2/darwin-thread-multi-2level/auto/SVN/_Core
find: /usr/lib/cron/tmp: Permission denied
```

- `/usr/local/opt/subversion/lib/perl5/site_perl/5.28.2/darwin-thread-multi-2level/auto`のシンボリックリンクを`/usr/local/Cellar/git/2.31.1/share/perl5`に作成する。

```
ln -sf \
    /usr/local/opt/subversion/lib/perl5/site_perl/5.28.2/darwin-thread-multi-2level/auto \
    /usr/local/Cellar/git/2.31.1/share/perl5
```

- 現在の`/usr/local/Cellar/git/2.31.1/share/perl5`ディレクトリ

```
$ ls -l /usr/local/Cellar/git/2.31.1/share/perl5
drwxr-xr-x  FromCPAN/
drwxr-xr-x  Git/
-rw-r--r--  Git.pm
drwxr-xr-x  Net/
lrwxr-xr-x  SVN@ -> /usr/local/opt/subversion/lib/perl5/site_perl/5.28.2/darwin-thread-multi-2level/SVN
lrwxr-xr-x  auto@ -> /usr/local/opt/subversion/lib/perl5/site_perl/5.28.2/darwin-thread-multi-2level/auto
```

- `git svn --version`の確認。

```
$ git svn --version
git-svn version 2.31.1 (svn 1.14.1)
```

- Subversionリポジトリからpullできるかを確認。

```
$ git svn rebase
Current branch main is up to date.
```

- `/usr/local/opt/subversion/lib/perl5/site_perl/`のバージョンと`/usr/local/Cellar/git/`のバージョンが変更されたら`.../SVN`と`.../auto`のシンボリックリンクを作り直す。