Git 命令在 Mac 终端中不起作用:“dyld:找不到符号:___strlcpy_chk”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20929689/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 17:32:00  来源:igfitidea点击:

Git commands not working in Mac terminal: "dyld: Symbol not found: ___strlcpy_chk" error

macosgitversion-controlterminalclone

提问by KateMak

I am using the command git clone ssh://.... and getting the following error on the terminal:

我正在使用命令 git clone ssh://.... 并在终端上收到以下错误:

dyld: lazy symbol binding failed: Symbol not found: ___strlcpy_chk
  Referenced from: /usr/local/git/bin/git
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: ___strlcpy_chk
  Referenced from: /usr/local/git/bin/git
  Expected in: /usr/lib/libSystem.B.dylib

Trace/BPT trap: 5

回答by KateMak

I needed to install command line tools from Xcode. To do so-

我需要从 Xcode 安装命令行工具。这样做——

  1. Open Xcode and hit Cmd+,
  2. Click Downloads
  3. Install command line tools.
  1. 打开 Xcode 并点击Cmd+,
  2. 点击下载
  3. 安装命令行工具。

http://www.hongkiat.com/blog/mountain-lion-git-fix/

http://www.hongkiat.com/blog/mountain-lion-git-fix/

回答by Dana

Had the same problem. I have OS X 10.8, so XCode was not a solution for me.

有同样的问题。我有 OS X 10.8,所以 XCode 不是我的解决方案。

Turns out I had a Git version that's not compatible with my OS X version

原来我有一个与我的 OS X 版本不兼容的 Git 版本

This info might help(found it googling :) ):

此信息可能会有所帮助(通过谷歌搜索发现它 :) ):

If you are running:

如果您正在运行:

  • 10.6 Snow Leopard: git-2.2.1-intel-universal-snow-leopard
  • 10.7 Lion: git-2.2.1-intel-universal-snow-leopard
  • 10.8 Mountain Lion: git-2.2.1-intel-universal-snow-leopard
  • 10.9 Mavericks: git-2.2.1-intel-universal-mavericks
  • 10.10 Yosemite: git-2.2.1-intel-universal-mavericks
  • 10.6 雪豹:git-2.2.1-intel-universal-snow-leopard
  • 10.7 Lion:git-2.2.1-intel-universal-snow-leopard
  • 10.8 山狮:git-2.2.1-intel-universal-snow-leopard
  • 10.9 小牛队:git-2.2.1-intel-universal-mavericks
  • 10.10 优胜美地:git-2.2.1-intel-universal-mavericks

You can download from here: http://sourceforge.net/projects/git-osx-installer/files/

您可以从这里下载:http: //sourceforge.net/projects/git-osx-installer/files/

回答by Cronk

I was also having troubles with the same error. I tried the PATH and .bash_profile tricks (didn't help). I wasn't really interested in installing Xcode and then the 'Command Line Tools' as others had suggested. But I did stumble upon half an answer.

我也遇到了同样的错误。我尝试了 PATH 和 .bash_profile 技巧(没有帮助)。我对安装 Xcode 和其他人建议的“命令行工具”并不真正感兴趣。但我确实偶然发现了一半的答案。

First, I uninstalled my current version of Git (1.9.2). I then found that it is possible to install the Command Line Tools by themselves, without installing Xcode:

首先,我卸载了当前版本的 Git (1.9.2)。然后我发现可以自己安装命令行工具,而无需安装Xcode:

Xcode page:  https://developer.apple.com/xcode/
Downloads near the top
Scroll down to 'Additional Tools'->'View Downloads'
Command Line Tools (OS X Mountain Lion)

With those installed, doing 'git --version' returned this:

安装后,执行 'git --version' 返回:

git version 1.8.5.2 (Apple Git-48)

The file "/usr/lib/libSystem.B.dylib" was untouched during this process. Or at least, the file size and date did not change. Since that library didn't change, I would surmise that it isn't Xcode that is fixing things, but the version of Git that is installed.

在此过程中,文件“/usr/lib/libSystem.B.dylib”未受影响。或者至少,文件大小和日期没有改变。由于该库没有改变,我推测修复问题的不是 Xcode,而是安装的 Git 版本。

I thought about testing that theory and found the older source code for various versions of Git, but didn't have time to spend compiling/installing/testing each one to see if this theory is correct. And I didn't see a simple method of uninstalling the 'command line tools'. Maybe someone else is more intrepid. :)

我想测试这个理论并找到了各种版本的 Git 的旧源代码,但没有时间花时间编译/安装/测试每个版本来看看这个理论是否正确。而且我没有看到卸载“命令行工具”的简单方法。也许别人更勇敢。:)

-- J

——J

回答by johnfo

The issue is that the git maintainers only support MaxOS10.9 (mavericks). If you have an earlier version, you can't use their distribution.

问题是 git 维护者只支持 MaxOS10.9(小牛)。如果您有较早的版本,则不能使用它们的发行版。

Recommended by somebody else at work - use (home)brew. Basically with brew installed you can merely use:

其他人在工作中推荐 - 使用(home)brew。基本上安装了 brew 后,您只需使用:

brew install git

and it will give you an up to date version. Subsequently to get a new version use:

它会给你一个最新的版本。随后获得新版本使用:

brew upgrade git

Now brew itself uses git, so it might be that this install is recursive - I had to install it recently for another purpose and it took me several hours - but once you have it there, things should be OK. All I can say is that when I installed brew originally, "git" still referred to the 1.8.x Apple version, and with this change I'm now getting git v2.1.0.

现在 brew 本身使用 git,所以可能是这个安装是递归的——我最近不得不为了另一个目的安装它,这花了我几个小时——但是一旦你在那里安装它,事情应该没问题。我只能说,当我最初安装 brew 时,“git”仍然指的是 1.8.x Apple 版本,通过这个更改,我现在得到了 git v2.1.0。

回答by Base_v

One can also look at https://stackoverflow.com/a/19457333/894120and just make a .bash_profile, that worked for me.

还可以查看https://stackoverflow.com/a/19457333/894120并制作一个对我有用的 .bash_profile。

回答by Kiki Jewell

I was also plagued with git causing the dreaded:

我也被 git 困扰,导致可怕的:

dyld: lazy symbol binding failed: Symbol not found: ___strlcpy_chk
Referenced from: /usr/local/bin/git
Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: ___strlcpy_chk
Referenced from: /usr/local/bin/git
Expected in: /usr/lib/libSystem.B.dylib

After reading many successfully executed suggestions revolving around updating xCode (>2G) or just the Command Line Tools part of xCode (~200M) I installed the Command Line Tools and this fixed my problem when using git from the command line.

在阅读了许多围绕更新 xCode (>2G) 或仅 xCode 的命令行工具部分 (~200M) 成功执行的建议后,我安装了命令行工具,这解决了从命令行使用 git 时的问题。

Interestingly, I was having trouble with PyCharm getting the same error, even after I did the update. I was able to fix this by changing the path where git was found (In PyCharm->Preferences...->Version Control->Git, I changed /usr/local/bin/git to /usr/bin/git near the top):

有趣的是,即使在我进行了更新之后,PyCharm 也遇到了同样的错误。我能够通过更改找到 git 的路径来解决此问题(在 PyCharm->Preferences...->Version Control->Git 中,我将 /usr/local/bin/git 更改为 /usr/bin/git 附近的最佳):

Image of PyCharm->Preferences...->Version Control->Git

PyCharm->Preferences...->Version Control->Git 的图片

I finally figured out exactly what's going on -- and to pay homage to all the help I received from the web, want to share the specifics:

我终于弄清楚到底发生了什么 - 并向我从网上收到的所有帮助表示敬意,想分享具体细节:

I discovered there were two versions of git installed on my machine:

我发现我的机器上安装了两个版本的 git:

/usr/bin/git 
/usr/local/git/bin/git 
(also interestingly: /usr/local/bin/git -> ../git/bin/git)

Some suggestions for putting /usr/bin in the path are somewhat helpful, but might not solve the niggling problem that there's a version of git installed that doesn't work.

将 /usr/bin 放在路径中的一些建议有些帮助,但可能无法解决安装的 git 版本不起作用的棘手问题。

So note this:

所以请注意:

$ pwd 
/usr/local/git/bin 
$./git --version 
git version 2.8.1

And:

和:

$ pwd 
/usr/bin 
$ ./git --version 
git version 1.8.5.2 (Apple Git-48)

The Apple git version is the one that works -- this is the one likely installed by installing the Command Line Tools from xCode. Note the paths in each. Also note that you don't necessarily have to install the whole Command Line Tools, just a proper version of git.

Apple git 版本是有效的版本——这很可能是通过从 xCode 安装命令行工具来安装的。注意每个路径。另请注意,您不必安装整个命令行工具,只需安装适当版本的 git。

Further, in the /usr/local/git/bin/ directory, there's an uninstall.sh script. In that script, it uses pkgutil to uninstall the version of git. (You should use this script to do the uninstall.) You can run this line to verify that this utility has record of installing git:

此外,在 /usr/local/git/bin/ 目录中,有一个 uninstall.sh 脚本。在该脚本中,它使用 pkgutil 卸载 git 版本。(您应该使用此脚本来执行卸载。)您可以运行此行来验证此实用程序是否有安装 git 的记录:

pkgutil --packages | grep com.git.pkg

This is not the version you want. You want the Apple version. Use the script in the /usr/local/git/bin to uninstall the broken version of git.

这不是您想要的版本。你想要苹果版。使用 /usr/local/git/bin 中的脚本卸载损坏的 git 版本。

Uninstalling it assures you will never get this error, and that you will be using the proper version of git.

卸载它可确保您永远不会收到此错误,并且您将使用正确版本的 git。

Hope that helps some others. The info was good but incomplete. And there was almost nothing for PyCharm.

希望能帮助其他人。信息很好,但不完整。而 PyCharm 几乎什么都没有。