刚上手mac系统,打算安装nvm时,brew上来就给我邦邦两拳
mac@macdeMBP ~ % brew install nvm
Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services, skipping update!
==> Fetching nvm
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles//nvm-0.39.
Already downloaded: /Users/mac/Library/Caches/Homebrew/downloads/2ae500a8baea60fbb1e274d5c0a606f4eb3f4f7a68795e4d0d5791460e01b457--nvm-0.39.3.all.bottle.tar.gz
fatal: not in a git directory
Error: Command failed with exit 128: git
大概意思就是brew的安装目录被git认为不是一个安全的目录,需要手动添加信任,解决方案:打开终端输入
brew -v
然后你会看到:
mac@macdeMBP ~ % brew -v
Homebrew 4.0.9-75-gc271a9a
fatal: detected dubious ownership in repository at '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'
To add an exception for this directory, call:
git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
Homebrew/homebrew-core (no Git repository)
fatal: detected dubious ownership in repository at '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'
To add an exception for this directory, call:
git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
Homebrew/homebrew-cask (no Git repository)
复制上面的命令提示,分别输入:
git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
然后完美解决~