I installed Homebrew on my Linux machine under one user account a while back. When I went to set up a second account, I assumed it would be as simple as dropping the shell env line into .bashrc. It wasn't - and the fix required solving two separate problems in order.
The first error is straightforward:
Error: /home/linuxbrew/.linuxbrew/Cellar is not writable.
The fix is to create a shared group, add both users to it, and set group ownership and permissions on the entire Homebrew tree:
# Create a shared group
sudo groupadd linuxbrew
# Add both users
sudo usermod -aG linuxbrew user1
sudo usermod -aG linuxbrew user2
# Set group ownership and permissions
sudo chgrp -R linuxbrew /home/linuxbrew/.linuxbrew
sudo chmod -R g+rwx /home/linuxbrew/.linuxbrew
# Set the setgid bit so new files inherit the group
sudo find /home/linuxbrew/.linuxbrew -type d -exec chmod g+s {} \;
# Let the second user traverse the parent directory
sudoOccasional notes on software, tools, and things I learn. No spam.
Unsubscribe anytime.
Log out and back in for the group membership to take effect.
After fixing permissions, brew update started throwing a different error:
Warning: No remote 'origin' in /home/linuxbrew/.linuxbrew/Homebrew, skipping update!
fatal: detected dubious ownership in repository at '/home/linuxbrew/.linuxbrew/Homebrew'
This is Git's safe-directory check. The Homebrew repo is owned by the first user, so Git refuses to operate on it when the second user runs brew. The fix is to mark the Homebrew directories as trusted for the second user:
git config --global --add safe.directory /home/linuxbrew/.linuxbrew/Homebrew
git config --global --add safe.directory /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core
# add any other tap paths that show up in the errorAfter that, brew update ran cleanly and everything worked as expected.
To share a Linuxbrew install across accounts: fix group ownership so both users can write to the cellar, then mark the Homebrew Git repos as safe directories for each additional user. Two separate problems, two separate fixes - but neither is complicated once you know what you're looking at.