Blog | Phodal - A Growth Engineerhttp://www.phodal.com/blog/2016-07-07T13:51:57.087662+00:00BlogHomebrew 修复大作战2016-07-07T13:30:05+00:002016-07-07T13:51:57.087662+00:00Phodal Huanghttp://www.phodal.com/blog/author/root/http://www.phodal.com/blog/homebrew-fix-series-issue/在升级git成2.9的时候,终于遇到了之前升级时Homebrew的坑,于是只好一个个来修复。
执行:
```shell
brew doctor
```
返回了一系列很长的日志,于是便保存了日志,然后一个个处理。
```shell
nohup brew doctor > log.log
```
第一个问题比较简单,并且也有一个相对简单的解决方案,即: ``brew prune``
```
Warning: Broken symlinks were found. Remove them with `brew prune`:
/usr/local/bin/2to3-3.4
/usr/local/bin/N1
/usr/local/bin/TexturePacker
/usr/local/bin/aclocal
/usr/local/bin/aclocal-1.14
/usr/local/bin/automake
```
于是,便执行了这个命令:
```shell
brew prune
```
然后遇到了权限问题:
```shell
Error: Permission denied - /usr/local/share/ghostscript/9.16/Resource/CIDFont/HiraKakuPro-W3
```
就可以用下面的命令来解决这个问题了:
```shell
sudo chown -R "$USER":admin /usr/local
```
随后,终于成功修复了第一个问题。
```
Pruned 484 symbolic links and 317 directories from /usr/local
```
接着,遇到一系列的多出来的库的问题:
```shell
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/libffi.6.dylib
/usr/local/lib/libjlinkpic32.4.90.1.dylib
/usr/local/lib/libmcrypt.4.4.8.dylib
```
删除之:
```
rm /usr/local/lib/libmcrypt.4.4.8.dylib
```
以及多出来的头文件:
```
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
/usr/local/include/Extras/OVR_Math.h
/usr/local/include/Kernel/OVR_Alg.h
/usr/local/include/Kernel/OVR_Allocator.h
```
还有la文件:
```
Warning: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .la files:
/usr/local/lib/libffi.la
/usr/local/lib/libmcrypt.la
```
pc文件:
```
Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .pc files:
/usr/local/lib/pkgconfig/glfw3.pc
```
以及静态库:
```
Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected static libraries:
/usr/local/lib/libappfirewall.a
/usr/local/lib/libautoblock.a
```
接着就是修复一些没有link的库的问题了:
```
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
binutils
erlang
gcc
gnutls
```
```
brew link binutils
```
```
Linking /usr/local/Cellar/binutils/2.25.1...
Error: Could not symlink share/info/bfd.info
Target /usr/local/share/info/bfd.info
is a symlink belonging to gdb. You can unlink it:
brew unlink gdb
To force the link and overwrite all conflicting files:
brew link --overwrite binutils
To list all files that would be deleted:
brew link --overwrite --dry-run binutils
```
重新安装之:
```shell
brew uninstall binutils
brew install binutils
```
还有一个更有意思的问题,这时候只好一个个的将这些第三方库清空:
```
Error: uninitialized constant AbstractPhpVersion::Php70Defs
Please report this bug:
https://git.io/brew-troubleshooting
/usr/local/Library/Taps/homebrew/homebrew-php/Abstract/abstract-php-extension.rb:216:in `<class:abstractphp70extension>'
/usr/local/Library/Taps/homebrew/homebrew-php/Abstract/abstract-php-extension.rb:215:in `<top (required)="">'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
```
先删了再说:
```
rm -rf /usr/local/Library/Taps/josegonzalez/homebrew-php
```
还有需要安装的依赖
```
Warning: Some installed formula are missing dependencies.
You should `brew install` the missing dependencies:
brew install docker-machine hicolor-icon-theme ocaml qt qt5
```
不需要的依赖:
```
You may wish to `brew unlink` these brews:
libxml2
libxslt
openssl
homebrew/versions/tomcat6
```
以及一些配置问题——即在$PATH后面多了一个"/"
```
Warning: Some directories in your path end in a slash.
Directories in your path should not end in a slash. This can break other
doctor checks. The following directories should be edited:
/Users/fdhuang/gocode/bin/
/usr/local/sbin/
/usr/local/gcc_arm/gcc-arm-none-eabi-4_8-2014q3/bin/
/Library/TeX/texbin/
```
然后执行
```
brew update
```
又有一堆错误:
```
error: refs/remotes/origin/gh-pages does not point to a valid object!
error: refs/remotes/origin/gnome-releases does not point to a valid object!
error: refs/remotes/origin/go does not point to a valid object!
error: refs/remotes/origin/gh-pages does not point to a valid object!
error: refs/remotes/origin/gnome-releases does not point to a valid object!
error: refs/remotes/origin/go does not point to a valid object!
```
</top></class:abstractphp70extension>