5

I work with Yosemite (10.10.3) and would like to upgrade bash (to version 4.x) and found this post. After brew update, I did brew install bash, but obtained:

==> Downloading https://homebrew.bintray.com/bottles/bash-4.3.33.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring bash-4.3.33.yosemite.bottle.tar.gz
==> Caveats
In order to use this build of bash as your login shell,
it must be added to /etc/shells.
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied - /usr/local/share/locale/af
Error: Permission denied - /usr/local/share/locale/af

How can I fix this? I cded into /usr/local/share/locale but the directory af doesn't exist. Why does brew try to access this?

Update

I forgot to say, if I use sudo brew install bash, I receive:

Error: Cowardly refusing to `sudo brew install`
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.
2
  • Open a terminal window and sudo chown -R <yourusername> /usr/local ?
    – mdpc
    Commented Jun 4, 2015 at 23:26
  • 4
    Do not do this. You're opening up a major security vulnerability if you do. Commented Jun 5, 2015 at 0:26

2 Answers 2

3

You must be sure that the group of /usr/local and all inside it is admin (I'm supposing your username belongs to admin group too). If this isn't the case, fix it with:

sudo chown -R $USER:admin /usr/local

You will probably have to do the same on /Library/Caches/Homebrew:

sudo chown -R $USER:admin /Library/Caches/Homebrew
10
  • Hi, thanks for helping. I did that (yes, my username belongs to the admin group). After that, brew install bash gave Warning: bash-4.3.33 already installed, it's just not linked. But brew link bash gave Linking /usr/local/Cellar/bash/4.3.33... Error: Permission denied - /usr/local/share/locale/af. As I said in my post, the subfolder af of /usr/local/share/locale does not exist. Shall I create it? Why does brew want to install/link in there?
    – mathlete
    Commented Jun 5, 2015 at 10:36
  • Reinstall it. brew uninstall bash and then brew install bash.
    – jherran
    Commented Jun 5, 2015 at 10:40
  • ... that's exactly what I tried, too. And ended up with the same result (obtaining Error: An unexpected error occurred during the 'brew link' step because of the permission denied error). I installed a lot of things with brew and it always worked. But the subdirectory af was never created it seems.
    – mathlete
    Commented Jun 5, 2015 at 10:41
  • Can you create a file on /usr/local to test that you have perms there?
    – jherran
    Commented Jun 5, 2015 at 10:45
  • I created a directory and a file, both worked.
    – mathlete
    Commented Jun 5, 2015 at 11:09
-1

This line:

sudo chown -R $USER:admin /usr/local

Worked for me.

1
  • Welcome to Ask Different. We like answers to be more than just a single line. Ideally, you want to explain why your answer is *right." It also helps to provide links, citations, and/or screen shots. Please review our help section How to Answer on writing good answers to questions
    – Allan
    Commented May 23, 2017 at 4:36

You must log in to answer this question.

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