3

Just yesterday I updated my machine, a MacBook Pro (Mid 2010), to macOS Sierra. Everything seems to work fine, except when I try to use the homebrew packet manager with any command, for example brew help, the following error message is printed:

/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:15:in `<main>'

I have not messed with anything related to ruby. Upon research I noticed that there seem to be some compatibility issues with Sierra and homebrew around, however, none seemed to match my problem exactly.

9
  • 1
    Have you tried reinstalling homebrew? I seem to recall having issues with it every time I update macOS.
    – Lizzan
    Commented Oct 7, 2016 at 11:25
  • I found the underlying issue as well as the answer and will post a link to a discussion shortly.
    – foobar
    Commented Oct 7, 2016 at 11:29
  • Or so I thought. Unfortunately the solution proposed on Reddit does not work for me. I get the same error even after running chmod and running this let's me cringe anyway.
    – foobar
    Commented Oct 7, 2016 at 11:42
  • Have you tried the following: brew doctor Commented Oct 7, 2016 at 11:49
  • I get the same error for every brew command, including this one. Seemingly, Sierra has reset the rights for /usr/local. Earlier versions of homebrew, however, need those rights. What I can't explain to myself is, why running chmod does not do the trick for me.
    – foobar
    Commented Oct 7, 2016 at 11:54

1 Answer 1

8

For the big picture: I solved the issue by uninstalling homebrew and then re-installing it again. In order to help people maybe gain a bit more insight, let me go into further detail.

Researching the Internet for the error message, my first hunch was that it had something to do with permissions. Check a discussion on Reddit or on the Homebrew GitHub for reference. However, running sudo chown -R $(whoami) /usr/local did not to the trick. In any way, I would advise to be very careful using this command as it will transfer the ownership of /usr/local from the root user to yourself, which, apparently, was not intended by Apple. You can undo this by running

sudo chmod 0755 /usr/local
sudo chown root:wheel /usr/local

However, note that this will only undo it for the folder /usr/local and not recursively for all its files.

So, I was left with uninstalling. If you want to do the same, type

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

in order to run the official script or see the Homebrew FAQ for reference. Be aware that this will also uninstall all your Formulae and that you will be left with installing them manually again later on.

To re-install homebrew, simply run

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

If anyone figures out why I got the error in the first place or how it can be addressed directly, please let me know.

2
  • I got the same error when I tried to update my homebrew with Ansible after upgrading to Sierra. Till I found your post, I was thinking that the Ansible module caused the problem, now it seems to be related to homebrew itself. Did you run brew update after installing Sierra?
    – lpacheco
    Commented Oct 31, 2016 at 9:30
  • Thanks for this! Just a small point in case it happens for anyone else - when running the uninstall script, the folders under /usr/local/ were not being deleted after the uninstall of brew. This then caused issue with the fresh installation. So I had to manually delete those folders before running the install script, and it all worked then! Commented Dec 5, 2016 at 13:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .