当我在终端中运行brew时,我得到一个错误:

 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- utils/popen (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Library/Homebrew/utils.rb:6:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Library/Homebrew/global.rb:9:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Library/brew.rb:16:in `<main>'

这些是我的宝石设置:

- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-02-24 patchlevel 451) [universal.x86_64-darwin13]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
  - ruby
  - universal-darwin-13
- GEM PATHS:
  - /Library/Ruby/Gems/2.0.0
  - /Users/ronaldkwan/.gem/ruby/2.0.0
  - /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
- GEM CONFIGURATION:
  - :update_sources => true
  - :verbose => true
  - :backtrace => false
  - :bulk_threshold => 1000

当前回答

在我看来,popen是一个C系统库,它的头文件丢失了。

检查您是否已经成功地使用命令行工具安装了xcode,并接受了许可证。

如何安装Xcode命令行工具

其他回答

更新到El Capitan后,/usr/local具有root:wheel权限。

使用以下命令将权限更改回用户:

sudo chown -R $(whoami):admin /usr/local

and:

brew doctor && brew update

这帮助我重新启动了Homebrew。

在我看来,popen是一个C系统库,它的头文件丢失了。

检查您是否已经成功地使用命令行工具安装了xcode,并接受了许可证。

如何安装Xcode命令行工具

首先我执行:

sudo chown -R $(whoami):admin /usr/local

然后:

cd $(brew --prefix) && git fetch origin && git reset --hard origin/master

要恢复您的Homebrew设置,请尝试以下操作:

cd /usr/local/Homebrew/Library && git stash && git clean -d -f && git reset --hard && git pull

在我的情况下,我只需要删除Homebrew的可执行文件使用:

sudo rm -f `which brew`

然后重新安装Homebrew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"