Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot update brew in MAC OS X el capitan and keep getting a Load error with `require`

Tags:

macos

homebrew

I am not sure why this is happening but I cannot update brew in my MAC OS X El Capitan. I did:

brew update

and got:

warning: unable to unlink CONTRIBUTING.md: Permission denied
warning: unable to unlink SUPPORTERS.md: Permission denied
fatal: cannot create directory at '.github': Permission denied

to go over that issue I sudoed the above command but got further issues:

sudo brew update
Password:
/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 -- mach (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/extend/pathname.rb:2: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:3: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>'

now whenever I do brew install I get:

brew update

/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 -- mach (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/extend/pathname.rb:2: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:3: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>'

in fact, it seems that whenever I do anything, like just type brew it gets the same message. Does anyone know how to fix this?

like image 973
Charlie Parker Avatar asked Mar 20 '16 22:03

Charlie Parker


People also ask

How do you fix a Mac update error?

Turn on or restart your Mac, then immediately press and hold the Shift key as your Mac starts up. Release the key when you see the login window, then log in to your Mac. You might be asked to log in again. On either the first or second login window, you should see ”Safe Boot” in the upper-right corner of the window.

Why is my Mac not updating?

There are several reasons you might be unable to update your Mac. However, the most common reason is a lack of storage space. Your Mac needs to have enough free space to download the new update files before it can install them. Aim to keep 15–20GB of free storage on your Mac for installing updates.

What is brew Doctor Mac?

Brew Doctor is Homebrew's own self-diagnosis tool. Once this is done, you should run brew update in order to download new "formulae". Running Brew Update. Formulae are instructions for Homebrew on how to install specific software and where to find the necessary files and dependencies.


1 Answers

You shouldn’t use sudo with Homebrew. First run the following to ensure you own everything under /usr/local:

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

Alternative command for newer macOS version:

sudo chown -R $(whoami) $(brew --prefix)/*

Then reset your Homebrew repo to a clean state:

cd /usr/local && git fetch && git reset --hard origin/master

It should fix your issues.

(replace /usr/local with $(brew --prefix) if you installed Homebrew elsewhere)

like image 65
bfontaine Avatar answered Oct 16 '22 22:10

bfontaine