How to use Homebrew on a Multi-user MacOS Sierra Setup
I have a Mac that is shared between two engineers. Both have separate user accounts. Both need to run brew update and brew install. occasionally.
How do I set this up without getting errors like: /usr/local must be writable! ?
Yeah, I could have UserA take over the permissions of /usr/local every time he wants to use brew (and same with UserB ), but that seems like a lot of unnecessary trouble.
8 Answers 8
Hombrew installs packages in /usr/local , there is nothing you can do about that without breaking many of the packages it installs. Add read and write permissions for all users like this:
Be aware the since this is a system folder, all users will share the same brew installation. One user can remove packages that others have installed, and so on. So make sure to coordinate to avoid problems.
You can also change the group permissions to admin or another group that both of your users are in:
UPDATE:
In macOS High Sierra you can’t change the owner, group or permissions of /usr/local . So you have to change the group and permissions of the subfolders:
UPDATE September 2018, High Sierra 10.13.6
- Determine the path of the brew prefix, ie. the path that will be used to store files related to working with homebrew
- Check that all users on the system who need access to brew are in the admin group
- Optional Add a user to the admin group if a user needs access to brew
Will require access / privileges to use the sudo command
Unable to run `brew update` on macOS 10.13 High Sierra #3322
Comments
Copy link Quote reply
weicool commented Oct 15, 2017
I’m trying to run brew update on macOS 10.13 High Sierra, but get
Running brew doctor gives me outdated instructions that no longer apply to 10.13. I followed the instructions in #3228, running sudo chown -R $(whoami) $(brew —prefix)/* , but am still unable to run brew update .
Copy link Quote reply
JCount commented Oct 15, 2017
@weicool What is the output of ls -ld /usr/local ?
Copy link Quote reply
weicool commented Oct 16, 2017
drwxr-xr-x 25 root wheel 800 Oct 15 10:57 /usr/local/
Copy link Quote reply
JCount commented Oct 16, 2017
Ok, what’s the output of ls -ld /usr/local/* ?
Copy link Quote reply
weicool commented Oct 16, 2017
Copy link Quote reply
ilovezfs commented Oct 16, 2017
And what is the output of
Copy link Quote reply
MikeMcQuaid commented Oct 16, 2017
From the issue template:
Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you do not read fill out the issue template repeatedly you will be blocked from every submitting issues to Homebrew again.
Please add your brew config and brew doctor output ASAP.
Copy link Quote reply
ilovezfs commented Oct 17, 2017 •
@weicool Hmm . I saw brew config and brew doctor output from you via email (and also CC’d to the relevant GitHub addresses) but not posted on this issue. Did you maybe delete the posts? Or maybe GitHub somehow dropped them? Please make sure to post or re-post them on this issue itself.
Also, I still haven’t seen ls -al /usr/local/ output.
Copy link Quote reply
jmsundar commented Oct 18, 2017
Reinstalling homebrew worked. Found that solution at #3285. My specific error came when running brew upgrade .
Homebrew: Менеджер пакетов для OS X
Все менеджеры пакетов в Unix имеют определенные недостатки и большинство Linux-дистрибутивов пытаются по-разному эти недостатки обойти. В этом посте я расскажу про Homebrew — новый менеджер пакетов, нацеленный на простоту использования.
До Homebrew было несколько различных попыток создать эффективные пакетные менеджеры для OS X. Две наиболее популярные вылились в итоге в Fink и Macports, но у каждой из них все равно есть свои острые углы. В частности, в обоих создание своих пакетов или портов является черезчур сложным.
В Homebrew создавать новые пакеты и работать с ними проще пареной репы. Давайте посмотрим.
Что оно делает?
Основная мысль очень проста. Homebrew упрощает и автоматизирует монотонные действия по скачиванию и сборке пакетов. Если вам надоели бесконечные ./configure && make && make install , Homebrew поможет.
Зачем оно?
Как я уже заметил выше, для OS X уже есть два решения: Fink и MacPorts. Если какое-то из них у вас уже установлено и всем устраивает — отлично. Но если вы имели неудачный опыт с ними в прошлом, я сильно рекомендую попробовать Homebrew. С ним намного проще. Плюс, его легко модифицировать, ведь он состоит всего из нескольких сотен строк кода на Ruby.
Homebrew не навязывает никакой строгой структуры и путей. По-умолчанию, он устанавливается в /usr/local , но его можно поставить куда угодно. Все пакеты устанавливаются в директории в специальном «подвале» (cellar), например Cellar/git/1.6.5.4/ . После установки Homebrew делает симлинки в стандартные Unix-директории. Ручная установка каких-то пакетов не из Homebrew отлично уживается с ними.
Это редко может понадобиться, но пакеты можно ставить напрямую из систем контроля версий. Если у пакета есть публичный git, svn, cvs или mercurial репозиторий, всегда можно собрать самую свежую devel-версию прямо оттуда простым brew install .
Кстати, установка занимает меньше времени, поскольку Homebrew старается избегать дублирования пакетов. Например, она не ставит очередную версию Perl в качестве зависимости, поскольку в системе уже есть готовый и работающий Perl. Плюс, Homebrew задуман так, чтобы вам не приходилось использовать sudo при работе с пакетами.
Звучит неплохо. Как это установить?
Первая и единственная зависимость Homebrew — OS X Developer Tools, которые есть на любом установочном диске с OS X и доступны для бесплатного скачивания с сайта Apple.
Самое простое — установить в /usr/local . Это можно сделать весьма просто:
# Присваиваем папку /usr/local себе, чтобы не использовать sudo
sudo chown -R `whoami` /usr/local
# Чиним права на mysql, если он у вас установлен
sudo chown -R mysql:mysql /usr/local/mysql
# Скачиваем и устанавливаем Homebrew с гитхаба
curl -L github.com/mxcl/homebrew/tarball/master | tar xz —strip 1 -C /usr/local
Все, установка завершена. Давайте проверим что все работает:
brew install wget
brew info git
На сайте Homebrew есть wiki, где можно почитать всякого интересного про интеграцию с Rubygems, CPAN и Python EasyInstall.
Следить за обновлениями Homebrew тоже достаточно просто:
brew install git
brew update
Если у вас установлен git, вы можете в любой момент обновлять репозитории Homebrew и устанавливать последнии версии пакетов.
Создавать свои пакеты почти так же просто. Например, если бы в Homebrew не было бы пакета для wget, его создание выглядело бы примерно так:
brew create ftp.gnu.org/gnu/wget/wget-1.12.tar.bz2
После сохранения пакета, его можно протестировать: brew install -vd wget . Если что-то работает неправильно и вам нужна помощь по настройке пакета, на wiki есть много документации. Еще там можно посмотреть примеры создания таких пакетов как git или flac.
Если вы создали новый пакет и желаете поделиться им с сообществом, это тоже достаточно просто сделать с помощью гема github.
gem install json github
git add .
git commit -m «Added a formula for wget»
github fork
git push mastergitx
После того, как вы сделаете push, нужно в Homebrew issue tracker создать новый тикет с темой «New formula: ». Если там все в порядке, ваш пакет будет добавлен в главный репозиторий Homebrew и доступен всем пользователям.
Homebrew
The Missing Package Manager for macOS (or Linux)
Install Homebrew
Paste that in a macOS Terminal or Linux shell prompt.
The script explains what it will do and then pauses before it does it. Read about other installation options.
What Does Homebrew Do?
Homebrew installs the stuff you need that Apple (or your Linux system) didn’t.
Homebrew installs packages to their own directory and then symlinks their files into /usr/local .
Homebrew won’t install files outside its prefix and you can place a Homebrew installation wherever you like.
Trivially create your own Homebrew packages.
It’s all Git and Ruby underneath, so hack away with the knowledge that you can easily revert your modifications and merge upstream updates.
Homebrew formulae are simple Ruby scripts:
Homebrew complements macOS (or your Linux system). Install your RubyGems with gem and their dependencies with brew .
«To install, drag this icon. » no more. brew cask installs macOS apps, fonts and plugins and other non-open source software.
Making a cask is as simple as creating a formula.
‘brew update’ errors on MacOS 10.13 (High Sierra) #3285
Comments
Copy link Quote reply
JustinTRoss commented Oct 8, 2017 •
Please always follow these steps:
- Confirmed this is a problem with running a brew command and not brew install ing or the post-install behaviour of one or more formulae? If it’s a formulae-specific problem please file this issue at the relevant tap e.g. for Homebrew/homebrew-core https://github.com/Homebrew/homebrew-core/issues/new
- Ran brew update and retried your prior step?
- Ran brew doctor , fixed all issues and retried your prior step?
- Ran brew config and brew doctor and included their output with your issue?
To help us debug your issue please explain:
- What you were trying to do (and why)
I have updated to MacOS 10.13 (High Sierra). I am trying to run ‘brew update’ for the first time since the update. - What happened (include command output)
Output:
- What you expected to happen
Homebrew should update. - Step-by-step reproduction instructions (by running brew commands)
brew update after updating to 10.13
I ran brew doctor and received the following list of instructions:
As you’re likely aware, ‘/usr/local’ is not writeable in 10.13. I tried the same with ‘/usr/local/include’ as suggested by another issue. This did not work.
My version is a bit outdated:
I suspect uninstalling and reinstalling will solve my problems.