dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

adds fixbrew alias

Open jfmercer opened this issue 9 years ago • 3 comments

This adds a clever, unix-y alias to change a user's Homebrew files back to the correct user and group.

alias fixbrew='chown -R `whoami`:admin $(brew --prefix)'

jfmercer avatar Mar 31 '15 23:03 jfmercer

I’m not familiar with this problem. Could you elaborate?

mathiasbynens avatar Apr 01 '15 07:04 mathiasbynens

Uncommonly, homebrew users run into permission errors when using homebrew. (If you like, I could show you dozens of links, especially to Stack Exchange sites, to support this assertion.) The homebrew wiki suggests the following to fix such errors:

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

However, this is incomplete in two respects. First, it doesn't include the group (i.e., chown user:group). Secondly, it assumes that the HOMEBREW_PREFIX is always /usr/local, whereas, in rare cases, users choose a custom HOMEBREW_PREFIX, such as /opt, /opt/brew or whatever.

Now, I suggest and alias

sudo chown -R $(whoami):admin $(brew --prefix)

to fix both problems. According to the homebrew install script, the group should be admin. This alias sets it to $USER:admin. Secondly, just in case the user has a custom HOMEBREW_PREFIX, this alias will fix permissions in the correct homebrew directory in all cases.

If you have more questions, please let me know. :-)

jfmercer avatar Apr 01 '15 12:04 jfmercer

On Mojave, in my experience, this step is no longer necessary.

ghost avatar Apr 11 '19 14:04 ghost