homebrew not working on OSX

2019-01-07 01:34发布

Getting this error when i run the brew command on terminal. Need help resolving.

 /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>'

here are my env gem settings:

  • 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

7条回答
淡お忘
2楼-- · 2019-01-07 01:58

The problem mainly occurs after updating OS X to El Capitan (OS X 10.11) or macOS Sierra (macOS 10.12). This is mainly because of file permission issues with El Capitan’s or later macOS's new SIP process. Try changing permissions of /usr/local directory.

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

If it still doesn't work, use following steps and everything will be fine. This may be because homebrew is not updated.

1. open terminal  
2. $ cd /usr/local/Library/Homebrew  
3. $ git reset --hard  
4. $ git clean -df
5. $ brew update
查看更多
▲ chillily
3楼-- · 2019-01-07 01:59

In my case I just needed to remove brew executable:

sudo rm -f `which brew`

Then reinstall homebrew again:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
查看更多
仙女界的扛把子
4楼-- · 2019-01-07 02:03

Uninstall homebrew:

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

Then reinstall

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

Warning: This script will remove: /Library/Caches/Homebrew/ - thks benjaminsila

查看更多
smile是对你的礼貌
5楼-- · 2019-01-07 02:17

This issue should be fixed in newest version of homebrew. Just try to reinstall homebrew. How to is described here: Homebrew Homepage

查看更多
我欲成王,谁敢阻挡
6楼-- · 2019-01-07 02:20

After update to El Capitan, /usr/local directory has root:wheel rights. Change rights back to me

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

and

brew doctor && brew update

help me to get brew working again.

查看更多
神经病院院长
7楼-- · 2019-01-07 02:20

Firstly I executed...

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

Then...

cd $(brew --prefix) && git fetch origin && git reset --hard origin/master
查看更多
登录 后发表回答