在MacOS上,执行git svn clone命令时遇到了信号11错误。

13

我试图将一个项目从svn迁移到git。我之前使用的是osx svn包,但我也尝试了用Homebrew安装。但我一直收到相同的错误信息。

git svn clone http://myserver/myrepo
error: git-svn died of signal 11

版本信息:

git --version
git version 2.2.1

svn --version
svn, version 1.7.17 (r1591372)
   compiled Sep 18 2014, 13:06:44

我正在运行Yosemite操作系统。


我建议卸载它们,然后只下载XCode,因为它包含相对较新版本的git和svn。 - Thorbjørn Ravn Andersen
3
如果您在升级到Yosemite之前通过brew安装了git,您可能需要通过brew更新您的git安装(brew upgrade git)-因为brew中有与yosemite相关的修复(https://github.com/Homebrew/homebrew/issues/31310)。 - Mykola Gurov
git svn --version 显示什么?你必须在 git 仓库中执行此命令,无论是哪个仓库都可以。 - Schwern
3个回答

11

git svn 执行的是一个 Perl 程序 git-svn,它使用了与 libsvn 的绑定,而这些绑定比较敏感。如果 Perl 或 SVN 变化了,可能会导致段错误。在操作系统升级时,这两者都可能发生。

查找你的 git 正在使用哪个版本的 SVN 绑定。以下是我在 OS X 10.10.1 上得到的结果:

$ /usr/bin/git svn --version
git-svn version 1.9.3 (Apple Git-50) (svn 1.7.17)

尝试像评论中@MykolaGurov建议的那样,运行brew upgrade git。看起来有适用于10.10和git-svn的修复程序。您也可以尝试重新安装Perl绑定:brew reinstall subversion --with-perl

或者使用OS X提供的/usr/bin/git,它将与操作系统提供的SVN和Perl一起构建。

或者尝试MacPorts,我使用它,其git-svn可正常工作。port install git +svn


升级git后重新安装Perl绑定,效果非常好。谢谢! - BarFooBar
brew upgrade gitbrew reinstall subversion --perl 对我很有帮助。 - bnjmn
1
在升级 OS X 后:如果 brew upgrade git 告诉你最新版本已经安装,但仍然出现 signal 11 错误,请尝试使用 brew uninstall git 卸载 git,并重新安装 brew install git - Tim
1
在重新安装Subversion时从日志中得知:subversion: --perl已被弃用;使用--with-perl替代! - D. Josefsson
2
“--perl”/“--with-perl” 看起来不再是有效选项了。 - Pyves

5

首先要做的是通过添加GIT_TRACE=1来调试git命令,以查看它在哪个组件上失败,例如:

$ GIT_TRACE=1 git svn clone https://example.com/svn/foo/ foo
21:12:40.239238 git.c:557               trace: exec: 'git-svn' 'clone' 'https://example.com/svn/foo/ foo/' 'foo'
21:12:40.240158 run-command.c:347       trace: run_command: 'git-svn' 'clone' 'https://example.com/svn/foo/ foo/' 'foo'
error: git-svn died of signal 11

重新运行上一个命令,以在已损坏的仓库中显示崩溃发生在 git-svn 二进制文件中。

为了做到这一点,您需要确定您的 git-svn 二进制文件所在的位置,例如:

$ which -a git-svn
$ locate git-svn | grep git-svn$
/Applications/GitHub.app/Contents/Resources/git/libexec/git-core/git-svn
/Applications/SourceTree.app/Contents/Resources/git_local/libexec/git-core/git-svn
/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-svn
/Library/Developer/CommandLineTools/usr/libexec/git-core/git-svn
/usr/local/libexec/git-core/git-svn
/usr/local/Cellar/git/1.8.4.1/libexec/git-core/git-svn
/usr/local/Cellar/git/2.4.0/libexec/git-core/git-svn

如果你有多个git-svn二进制文件,想要查找正在使用的二进制文件,可以运行以下命令:

sudo fs_usage -f exec | grep git

在再次运行失败的git命令之前,请在另一个终端中执行以下操作。一旦确定你使用的是哪个git-svn版本,请直接运行它,例如:

/usr/local/libexec/git-core/git-svn ...
/usr/local/Cellar/git/2.4.0/libexec/git-core/git-svn 

很可能无论您指定哪个参数,它都会崩溃,否则请按照跟踪输出所示指定。

有时可能是符号链接,因此检查其指向的位置,例如:

$ stat /usr/local/libexec/git-core/git-svn
  File: ‘/usr/local/libexec/git-core/git-svn’ -> ‘/Applications/GitHub.app/Contents/Resources/git/libexec/git-core/git-svn’

如果是这种情况,请将符号链接更改为不会崩溃的链接,例如:
$ ln -vfs /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-svn /usr/local/libexec/git-core/git-svn 
‘/usr/local/libexec/git-core/git-svn’ -> ‘/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-svn’

或者确定您的 git-svn 属于哪个软件包并进行相应的升级,例如:

  • /Applications/Xcode.app -> upgrade Xcode,
  • /Applications/GitHub.app -> upgrade GitHub app
  • /usr/local/Cellar/git -> upgrade git via Homebrew, e.g.

    brew upgrade git
    

    If Homebrew will complain about the file conflicts, then run:

    brew link --overwrite git
    
如果您在升级后仍然出现崩溃,请使用不会崩溃的不同版本(如上所述),例如:
/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-svn clone https://example.com/svn/foo/ foo

如果这对你有用,将其添加到你的PATH中,并以后使用git-svn命令,或者添加一个别名,例如:
alias git-svn='/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-svn'

如果您的新git-svn缺少依赖项,请通过运行以下命令安装Git::SVN
sudo cpan install Git::SVN

调试

如果上述方法无法解决问题,您可以进一步进行调试。以下是一些建议,在单独的终端中运行,然后运行失败的命令:

sudo dtruss -fn git

或者:

sudo dtruss -fn git-svn

为了确定调用哪个 git-svn,您可以尝试以下方法:

  • sudo /usr/bin/newproc.d
  • sudo fs_usage -f exec | grep git

0

我的情况有些不同。我在 https url 中指定了我的 svn 仓库的凭据。 删除了这些凭据后问题得到解决。

我是如何运行命令的

git svn https://<key>:<pass>@example.com/repo

移除了密钥/密码并通过了命令。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接