git-gui命令在macOS Sierra上崩溃

52

在升级至 macOS Sierra 后,git-gui 命令会崩溃并显示以下错误:

Wish[23862:202062] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [0 nan]'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff8cd9252b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fffa146acad objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff8ce10a0d +[NSException raise:format:] + 205
    3   QuartzCore                          0x00007fff92938980 _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 152
    4   QuartzCore                          0x00007fff92938af5 -[CALayer setPosition:] + 44
    5   QuartzCore                          0x00007fff9293914b -[CALayer setFrame:] + 644
    6   CoreUI                              0x00007fff986e2112 _ZN20CUICoreThemeRenderer26MakeOrUpdateScrollBarLayerEPK13CUIDescriptoraPP7CALayer + 1284
    7   CoreUI                              0x00007fff986de317 _ZN20CUICoreThemeRenderer19CreateOrUpdateLayerEPK13CUIDescriptorPP7CALayer + 1755
    8   CoreUI                              0x00007fff986604d1 _ZN11CUIRenderer19CreateOrUpdateLayerEPK14__CFDictionaryPP7CALayer + 175
    9   CoreUI                              0x00007fff98663185 CUICreateOrUpdateLayer + 221
    10  AppKit                              0x00007fff8b3c7623 -[NSCompositeAppearance _callCoreUIWithBlock:options:] + 226
    11  AppKit                              0x00007fff8aa74a9d -[NSAppearance _createOrUpdateLayer:options:] + 76
在AppKit中,NSScrollerImp _animateToRolloverState和__49-[NSScrollerImp _installDelayedRolloverAnimation]_block_invoke方法可能会导致NSException异常的发生。同时,Foundation库的__NSFireDelayedPerform方法以及CoreFoundation库的__CFRunLoopDoTimer和__CFRunLoopRun等方法也与此有关。在此异常发生时,git-gui会因信号6而终止。是否有其他人遇到过这个问题并且有解决方案?

2
这个程序相关的内容翻译成中文:是否应该迁移到apple.SE? - dalearn
1
请注意,此问题已在macOS10.12.2及更高版本中解决。 - Kenn Sebesta
请注意,这在10.14.5中又出现了问题。 - Mathieu J.
14个回答

24

尝试执行以下命令:

git config --local --unset gui.geometry

出现该错误的原因是Tk Geometry管理器无法工作,可能是由于版本过旧或已损坏。

如果上述命令未起效,请尝试更新你的Xcode:

xcode-select --install

3
我尝试了这个解决方案,但对我无效。https://github.com/git/git-scm.com/issues/853 - sbondaryev
1
即使使用了 xcode-select --install 命令,似乎仍然无法正常工作。 - paulski
1
这对我有用,而且也很合理!谢谢。 - Mathieu J.

23

不要使用默认的MacOS tcl-tk,而是使用最新版本的tcl-tk(8.6.6)来自Homebrew,然后通过强行链接来连接它,例如:

brew install tcl-tk
brew link tcl-tk --force

谢谢,被采纳的答案对我没用,但这个可以。 - yxhuvud
这个答案对我有帮助,但只是在我解决了我的 PATH 变量问题之后才有效。我的 PATH 变量中 /usr/local/bin 前面有 /usr/bin/,导致我无法更改 gitk 使用的 Wish 版本。 - JBL
4
我需要执行 brew install homebrew/dupes/tcl-tk - pius
我尝试了这个……但是对我来说仍然崩溃。 - Clintm
1
brew install homebrew/dupes/tcl-tk 不再可用。homebrew/dupes已被弃用。 - ebelisle

19

在MacOS Sierra中,Tk 8.5存在问题。可以使用Tk Wish 8.4替换Tk Wish 8.5。

cp /System/Library/Frameworks/Tk.framework/Versions/8.4/Resources/Wish.app/Contents/MacOS/Wish /usr/local/Cellar/git/2.10.1/share/git-gui/lib/Git\ Gui.app/Contents/MacOS/

来源:https://github.com/git/git-scm.com/issues/853

更新:请注意将cp路径中的git版本更换为您当前使用的版本。


这对我没用。然而,ssahu的答案确实起作用了。 - yxhuvud
是的,ssahu的解决方案也应该可行,总之,思路是用另一个Tcl/tk 8.5版本替换它。您还应该在cp命令的目标路径中使用当前的git版本。 - sbondaryev
我建议升级Tk到8.6而不是降级到8.4,因为8.4有其自身的缺点。对我来说,很烦人的是它不支持我的MacBook的Retina显示屏。请参阅ssahu和Bruce的答案以了解如何做到这一点。 - pius
我尝试了许多解决方案,这是唯一一个对我有效的!谢谢!!!顺便提醒一下,也要注意使用您当前的Tk版本。 - Dmitry Kamenetsky

7

我的解决方法适用于从https://git-scm.com/下载的Git。

brew install homebrew/dupes/tcl-tk

进入 /usr/local/git/share/git-gui/lib/Git Gui.app/Contents/MacOS 目录并备份原始Wish

cp /usr/local/Cellar/tcl-tk/8.6.6/bin/wish8.6 /usr/local/git/share/git-gui/lib/Git Gui.app/Contents/MacOS/Wish


5

我从这里汇总了一堆答案,因为我正在使用GIT和通过brew安装的TCL:

  1. cd "/usr/local/Cellar/git/2.10.2/share/git-gui/lib/Git Gui.app/Contents/MacOS"
  2. mv Wish Wish.bkp
  3. ln -vs /usr/local/Cellar/tcl-tk/8.6.6/bin/wish8.6 Wish

随着时间的推移,版本号可能会有所不同。


5
我认为以下目标构成了解决问题的完整方案:
  • 通过简洁线性的方式,彻底解决这个问题

  • 避免使用旧版苹果Tcl/Tk导致字体难看

  • 将Git GUI与预装的苹果Tcl/Tk分离

    • 依赖Homebrew进行Tcl/Tk安装

下面是实现这些目标的逐步说明:

  1. Get the duplicated Tcl/Tk from Homebrew

    brew install tcl-tk
    
  2. Add the non-broken Tcl/Tk installation to the path(s) before the broken Apple implementation

    • This assumes your Homebrew paths take precedence over your system paths
    • This should be the case in a normal Homebrew installation
    • This will fail if you have conflicting files from your other installed homebrew recipes
    • For example the_platinum_searcher provides pt, which conflicts
    • I recommend ripgrep for getting around this case

      brew link --force tcl-tk
      
  3. Fix your gitk installation by reinstalling against the nonbroken Homebrew version

    • This might not be necessary, but ref. the first stated goal above

      brew reinstall git
      
  4. Copy the new wish binary from your Homebrew Tcl/Tk installation over the broken bundled one from Apple in the Git Gui.app bundle

    • This blindly relies on the ouput of homebrew info <package> to not change

      cp "$(which wish)" "$(brew info git | grep Cellar | cut -d' ' -f1)/share/git-gui/lib/Git Gui.app/Contents/MacOS/Wish"
      
最后一部分最好将其添加到您的~/.bashrc或等效文件中,因为每次从Homebrew获取新的git版本时都需要重复执行。
alias fix-gitgui='cp "$(which wish)" "$(brew info git | grep Cellar | cut -d" " -f1)/share/git-gui/lib/Git Gui.app/Contents/MacOS/Wish"'

我不完全确定为什么上面使用的cut命令中的字段分隔符字符的引用可以正常工作,因此请谨慎使用此别名,因为这很可能取决于确切的bash版本。


谢谢。在Mojave(10.14.3)上,别名对我有用,我很高兴将来能用它。错误:Wish [98243:1226829] ***在- [_ NSCGSWindow setFrame:]中的断言失败,/ BuildRoot / Library / Caches / com.apple.xbs / Sources / AppKit / AppKit-1671.20.108 / CGS.subproj / NSCGSWindow.m:1015 2019-03-21 11:55:18.876 Wish [98243:1226829] ***终止应用程序,因为未捕获异常'NSInternalInconsistencyException',原因是:“无效参数不满足:CGRectContainsRect(CGRectMake((CGFloat)INT_MIN,(CGFloat)INT_MIN,(CGFloat)INT_MAX-(CGFloat)INT_MIN,(CGFloat)INT_MAX-(CGFloat)INT_MIN),frame)” - Jason

2

0

我的Sierra(升级自10.11.6)的Tcl/Tk Current指向8.5,升级后我发现使用Tkinter的Python程序出现了同样的错误。我没有使用Wish。 Python 2.7 32位安装程序与Tcl/Tk 8.4连接无法帮助我,因为它不带有“tile”。所以我通过brew安装了我的Python,并将其连接到Tcl/Tk 8.6:

这是为了让brew使用预编译的bottles而不是从源代码构建,除非另有特别说明,因此并不是真正引起问题的原因:

xcode-select --install

然后安装Tcl/Tk:
brew install homebrew/dupes/tcl-tk

如果您最初没有使用--with-tcl-tk安装Python,则:

brew uninstall python

最后:

brew install python --with-tcl-tk

接下来,我使用与Tcl/Tk 8.6相关联的Python,看起来我已经解决了错误。


0

这个问题已经在最新的macOS Sierra补丁(10.12.2及以上版本)中得到解决,不需要采取进一步的行动。


我正在使用macOS Sierra 10.12.5(2017年8月),崩溃仍然存在。 - kenorb
你是如何安装git的?我使用homebrew安装,现在一切正常(似乎是Sierra更新修复了它,因为我没有更新git)。我已经重新安装了OSX,并使用brew重新安装了git,它工作得很好(就像我经常看到的其他2-3台Mac一样)。我无法保证从git网站下载的git安装程序的稳定性。我使用的是2015年15英寸rMBP和2013年13英寸rMBP,另一台Mac是大约2013年的Air。 - James Fry
我正在使用由brew安装的git 2.14.1版本,我尝试通过brew安装“ tcl-tk”,这对我很有帮助。 - kenorb
我只安装了以下的brew软件包 - freetds,freetype,git,graphicsmagick,imagemagick,jpeg,libpng,libtiff,libtool,openssl,pgloader,postgresql,readline,sbcl和xz。我正在运行10.12.6和brew 1.3.0。git --version报告“git版本2.14.0”,which git是“/usr/local/bin/git”。 - James Fry

0

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