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 Answers2

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
jherran
  • 13,284
  • 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? – Marius Hofert Jun 05 '15 at 10:36
  • Reinstall it. brew uninstall bash and then brew install bash. – jherran Jun 05 '15 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. – Marius Hofert Jun 05 '15 at 10:41
  • Can you create a file on /usr/local to test that you have perms there? – jherran Jun 05 '15 at 10:45
  • I created a directory and a file, both worked. – Marius Hofert Jun 05 '15 at 11:09
  • Weird. Last thing to try is to force reinstall (brew install bash --force). This should replace every single files copied before. – jherran Jun 05 '15 at 11:11
  • I get again Warning: bash-4.3.33 already installed, it's just not linked and when I do brew link bash the permission denied error appears again. I then created af by hand. brew was looking for LC_MESSAGES, so I simply copied that from the subdirectory de. Had to give it write permissions, but then I obtained the same permission denied warning, now for /usr/local/share/locale/bg... hmmm.. it seems these are country codes... I wonder how many I am missing... – Marius Hofert Jun 05 '15 at 11:21
  • I ran brew doctor and the first entry said that Warning: Some directories in /usr/local/share/locale aren't writable. This can happen if you "sudo make install" software that isn't managed by Homebrew. If a brew tries to add locale information to one of these directories, then the install will fail during the link step. You should probably 'chown' them... but @Froggard suggested not to do that... – Marius Hofert Jun 05 '15 at 11:28
  • Ok, I see. Try this: cd /usr/local/; sudo chown -R your-username *. Then reinstall bash again. – jherran Jun 05 '15 at 11:43
  • Hi, that worked, thanks. I had to register bash via sudo bash -c "echo /usr/local/bin/bash >> /private/etc/shells" (for all those who are interested in this) – Marius Hofert Jun 05 '15 at 11:49
-1

This line:

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

Worked for me.

Allan
  • 101,432
  • 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 May 23 '17 at 04:36