perl git-svnCore.pm全新安装macOS Catalina 10.15.4后无法找到SVN/ www.example.com

plicqrtu  于 2023-01-09  发布在  Perl
关注(0)|答案(6)|浏览(127)

最近我重新安装了macOS Catalina 10.15.4,在我安装了Command_Line_Tools_11.4.1之后,它告诉我svn不再支持Xcode,然后我用brew安装了git和svn,希望git-svn可以正常工作.不幸的是,我收到了这个错误消息:
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.
git和svn都是最新版本。
请帮帮我。

lyr7nygr

lyr7nygr1#

我终于想通了!
打开git-svn文件(perl脚本,在我的例子中文件位置是/usr/local/opt/git/libexec/git-core/git-svn),将第一行#!/usr/bin/perl更改为#!/usr/local/bin/perl
而且很管用!
我猜system perl没有包含perl SVN/Core,但是brew perl有(brew svn的依赖项)。

xxls0lw8

xxls0lw82#

    • 适用于MacOS Big Sur 11.5的解决方案**

在与此错误斗争了几个小时后:

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

我终于找到了一个有效的解决办法。
如果运行:

brew reinstall subversion

它将打印如下消息:

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

然后,在使用git svn从正确的路径加载SVN模块之前,您只需要运行以下命令:

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

puruo6ea3#

解决方案对于那些,像我一样-想要使用macOS Catalina上的sourcetree客户端与git-svn:
第一步:

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

第二步,安装缺少的Perl模块:

cpan SVN::Core
cpan Term::ReadKey

第三步,配置源树:
在资源树-〉首选项-设置选项"使用系统git",从:

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

hgc7kmma4#

虽然不是永久性修复,但解决方法是设置${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://...

为我工作,没有编辑任何脚本安装的brew。

zpjtge22

zpjtge225#

确保您已通过Homebrew安装Perl、Subversion和依赖项:

brew install perl subversion apr apr-util

将所需的Perl模块安装到~/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

通过以下方式验证安装的模块:

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

然后按如下所示配置Perl(基于brew info perl步骤):

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

最后运行Git的SVN:

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

如果你仍然卡住,尝试GitHub和GitLab网站,他们提供了Git/SVN迁移。
例如,在GitHub中,创建一个新的仓库,然后通过粘贴旧仓库的克隆URL导入项目。

c2e8gylq

c2e8gylq6#

错误消息显示:

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

这是因为git-svn是由Perl实现的,它需要一个名为SVN::Core的Perl库来运行.将git-svn脚本的第一行从#!/usr/bin/perl修改为#!/usr/local/bin/perl**不会修复这个错误!!! * 因为这只是将Perl库从system default version修改为brew installed version.如果brew installed version不包含SVN::Core,它仍然会失败:

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

注意,Perl版本已经更改,但是错误仍然存在,因为@INC指示的目录中没有SVN:Core
现在一些答案可能会告诉您按cpan SVN::Core安装SVN::Core,**不要这样做!!!**这不会解决问题!因为它安装的SVN::Core版本可能与您的SVN版本不匹配:

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

顺便说一下,cpan是垃圾,不要用它来安装任何东西。它在安装前编译源代码,但不能控制编译标志/选项,而且它不能卸载自己安装的东西。

    • 以下是正确的解决方案:**

在安装svn时已经安装了相应的Perl库,并且brew已经告诉您:

$ 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 ✘, python@3.9 ✔, scons ✘, swig ✘
Required: apr ✔, apr-util ✔, gettext ✔, lz4 ✔, openssl@1.1 ✔, 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)

我们可以看到Perl绑定位于/usr/local/opt/subversion/lib/perl5中,我们只需要让git-svn使用这个路径。稍微研究一下git-svn脚本,我们可以看到这个行为是由一个名为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 <normalperson@yhbt.net>
# License: GPL v2 or later

因此,解决此问题的正确方法是将以下代码添加到bashrczshrc

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

问题解决了!

相关问题