为什么 Homebrew 说 "no git repository"?

Why does Homebrew say "no git repository"?

运行 brew --config 给出

HOMEBREW_VERSION: >1.0.0 (no git repository)
...

为什么会这样?我能做些什么来修复它?


HOMEBREW_VERSION: >1.0.0 (no git repository)
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: bbed7246bc5c5b7acb8c1d427d10b43e090dfd39
Last commit: 4 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: ba0aa68066a89c0654152aba22819736b06987af
Core tap last commit: 77 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local/Homebrew
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: quad-core 64-bit haswell
Homebrew Ruby: 2.0.0-p648
Clang: 8.0 build 800
Git: 2.10.0 => /usr/local/bin/git
Perl: /usr/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/local/bin/ruby => /usr/local/Cellar/ruby/2.2.4/bin/ruby
Java: 1.8.0_102
macOS: 10.11.6-x86_64
Xcode: 8.0
CLT: 7.3.1.0.1.1461711523
X11: 2.7.9 => /opt/X11

如评论中所述,这是 Homebrew 本身的错误,由 issue #1091 描述。

此修复已由 this commit 合并:

- HOMEBREW_VERSION="$(git describe --tags --dirty 2>/dev/null)"
+ HOMEBREW_VERSION="$(GIT_DIR="$HOMEBREW_REPOSITORY/.git" git describe --tags --dirty 2>/dev/null)"
if [[ -z "$HOMEBREW_VERSION" ]]
then
  HOMEBREW_VERSION=">1.0.0 (no git repository)"