9

When trying to install R via Brew, I get the following output and errors:

==> Pouring pcre-8.43.mojave.bottle.tar.gz 
cp: /usr/local/Cellar/pcre/./8.43: 
cp: /var/folders/3l/zsdg6x9x61g8nhnb8f6pxzvw0000gn/T/d20190415-7574-1t8em0n/pcre/./8.43: unable to copy extended attributes to /usr/local/Cellar/pcre/./8.43: Permission denied
cp: /usr/local/Cellar/pcre/./8.43/INSTALL_RECEIPT.json: No such file or directory
cp: /usr/local/Cellar/pcre/./8.43/bin: No such file or directory

....

cp: utimes: /usr/local/Cellar/pcre/.: Operation not permitted
Error: Failure while executing; `cp -pR /var/folders/3l/zsdg6x9x61g8nhnb8f6pxzvw0000gn/T/d20190415-7574-1t8em0n/pcre/. /usr/local/Cellar/pcre` exited with 1. Here's the output:
cp: /usr/local/Cellar/pcre/./8.43: Permission denied
cp: /var/folders/3l/zsdg6x9x61g8nhnb8f6pxzvw0000gn/T/d20190415-7574-1t8em0n/pcre/./8.43: unable to copy extended attributes to /usr/local/Cellar/pcre/./8.43: Permission denied

....

Warning: Bottle installation failed: building from source.
Error: An exception occurred within a child process:
  Errno::EACCES: Permission denied @ dir_s_mkdir - /usr/local/Cellar/pcre/8.43

I'm installing this under an admin account. Via my normal non-admin account I get more trouble, and then have to chown many /usr/local folders, and don't think that's a good idea. Maybe for the brew-folders that is fine, but not for other stuff.

How can I install R and get it working?

SPRBRN
  • 8,149

3 Answers3

11

Maybe it is a problem about permission. According to the logs given above, I think the key point is the permission of /usr/local/Cellar/ or the sub/parent directory. Checking the permission maybe help.

To update the permission (if needed), use command:

sudo chown -R ${USER}:staff /usr/local/Cellar/

Peregrino69
  • 5,004
8

As Edenshaw commented:

sudo chown -R ${USER}:staff /usr/local/Cellar/

which solved the problem also for me after bad installation.

hhh
  • 703
  • 3
  • 9
  • 18
0

I had this same problem on a system shared with another user that had already installed brew.

Looks like brew uses a shared directory for all users and the first user owns the brew directories.

As such you don't actually need to change permissions as you can just add yourself to the group. (remember to logout/in after adding yourself to the group).

On my system the group was 'brew'.

You can check the group on your system by running:

ls -la /usr/local/Cellar/
ls -la /usr/local/Homebrew/Library/Taps/homebrew

Both of these directories should be owned by the same group.

If you have to change the paths because the current group isn't appropriate then run the following commands change 'brew' to the preferred group.

sudo chown -R ${USER}:brew /usr/local/Homebrew/Library/Taps/homebrew
sudo chown -R ${USER}:brew  /usr/local/Cellar/

All users of the system will need to be members of the 'brew' group.