Homebrew Multi-User Setup

On our computer, Daniel and I have two separate macOS users.

Originally I thought the best solution would be to create a UNIX group for both of us, and have it own the shared Homebrew installation. After reading more, I feel having a separate Homebrew installation for each of us would give us each the most freedom and protection.

This is the approach recommended on a less popular StackOverflow post as well as in the official Homebrew Multiple Installations instructions.

The original Homebrew installation that pydanny set up is at:

$ which brew
/usr/local/bin/brew
1
2

I set up a new Homebrew installation via Git checkout, in the place where I normally clone third-party projects:

cd $HOME/projects/third-party
git clone git clone git@github.com:Homebrew/homebrew-core.git
git clone git@github.com:Homebrew/brew.git
1
2
3

Then I added the new Homebrew installation path to my ~/.bashrc:

export PATH=$HOME/projects/third-party/brew/bin:$PATH
1

Source it (source ~/.bashrc) and verify that your new Homebrew path is correct:

$ which brew
/Users/arg/projects/third-party/brew/bin/brew
1
2

It's not perfect. I'll have to resolve this at some point:

MacBookPro2018:third-party arg$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: The following directories do not exist:
/Users/arg/projects/third-party/brew/etc
/Users/arg/projects/third-party/brew/include
/Users/arg/projects/third-party/brew/lib
/Users/arg/projects/third-party/brew/opt
/Users/arg/projects/third-party/brew/sbin
/Users/arg/projects/third-party/brew/share
/Users/arg/projects/third-party/brew/var/homebrew/linked
/Users/arg/projects/third-party/brew/Cellar

You should create these directories and change their ownership to your account.
  sudo mkdir -p /Users/arg/projects/third-party/brew/etc /Users/arg/projects/third-party/brew/include /Users/arg/projects/third-party/brew/lib /Users/arg/projects/third-party/brew/opt /Users/arg/projects/third-party/brew/sbin /Users/arg/projects/third-party/brew/share /Users/arg/projects/third-party/brew/var/homebrew/linked /Users/arg/projects/third-party/brew/Cellar
  sudo chown -R $(whoami) /Users/arg/projects/third-party/brew/etc /Users/arg/projects/third-party/brew/include /Users/arg/projects/third-party/brew/lib /Users/arg/projects/third-party/brew/opt /Users/arg/projects/third-party/brew/sbin /Users/arg/projects/third-party/brew/share /Users/arg/projects/third-party/brew/var/homebrew/linked /Users/arg/projects/third-party/brew/Cellar
==> Tapping homebrew/core
Cloning into '/Users/arg/projects/third-party/brew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 5020, done.
remote: Counting objects: 100% (5020/5020), done.
remote: Compressing objects: 100% (4821/4821), done.
remote: Total 5020 (delta 48), reused 578 (delta 9), pack-reused 0
Receiving objects: 100% (5020/5020), 4.00 MiB | 2.99 MiB/s, done.
Resolving deltas: 100% (48/48), done.
Tapped 2 commands and 4809 formulae (5,062 files, 12.4MB).

Warning: Your Homebrew's prefix is not /usr/local.
Some of Homebrew's bottles (binary packages) can only be used with the default
prefix (/usr/local).
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Discourse, Twitter or IRC. You are responsible for resolving any issues you
experience while you are running this unsupported configuration.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

Post-Setup Problems

Well, this didn't work as expected.

First Real-World Use: Installing Python 3

Installing Python 3 and all its dependencies appeared to work entirely as expected. I was feeling pretty confident about my Homebrew setup at this point.

$ brew install python3
Updating Homebrew...
==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
adwaita-icon-theme          docfx                       logstash                    s-lang
ammonite-repl               elasticsearch               metricbeat                  serverless
angular-cli                 exploitdb                   miller                      skaffold
ansible                     firebase-cli                minio                       snakemake
apib                        fonttools                   nats-streaming-server       snapcraft
apr-util                    gitmoji                     netdata                     snownews
auditbeat                   glooctl                     netlify-cli                 sshfs
bison                       helmfile                    opa                         starship
bit                         hugo                        passenger                   traefik
ccache                      icecream                    proteinortho                webpack
codespell                   istioctl                    pulumi                      wtfutil
conan                       kibana                      root

==> Installing dependencies for python: pkg-config, gdbm, openssl@1.1, readline, sqlite and xz
==> Installing python dependency: pkg-config
==> Downloading https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/Users/arg/projects/third-party/brew/Cellar/pkg-config/0.29.2 --disable-host-tool --wi
==> make
==> make check
==> make install
🍺  /Users/arg/projects/third-party/brew/Cellar/pkg-config/0.29.2: 11 files, 626.9KB, built in 1 minute 5 seconds
==> Installing python dependency: gdbm
==> Downloading https://homebrew.bintray.com/bottles/gdbm-1.18.1.mojave.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring gdbm-1.18.1.mojave.bottle.1.tar.gz
🍺  /Users/arg/projects/third-party/brew/Cellar/gdbm/1.18.1: 20 files, 586.8KB
==> Installing python dependency: openssl@1.1
==> Downloading https://www.openssl.org/source/openssl-1.1.1d.tar.gz
######################################################################## 100.0%
==> perl ./Configure --prefix=/Users/arg/projects/third-party/brew/Cellar/openssl@1.1/1.1.1d --openssldir=/User
==> make
==> make test
==> make install MANDIR=/Users/arg/projects/third-party/brew/Cellar/openssl@1.1/1.1.1d/share/man MANSUFFIX=ssl
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /Users/arg/projects/third-party/brew/etc/openssl@1.1/certs

and run
  /Users/arg/projects/third-party/brew/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /Users/arg/projects/third-party/brew,
because openssl/libressl is provided by macOS so don't link an incompatible version.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/Users/arg/projects/third-party/brew/opt/openssl@1.1/bin:$PATH"' >> ~/.bash_profile

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/Users/arg/projects/third-party/brew/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/Users/arg/projects/third-party/brew/opt/openssl@1.1/include"

For pkg-config to find openssl@1.1 you may need to set:
  export PKG_CONFIG_PATH="/Users/arg/projects/third-party/brew/opt/openssl@1.1/lib/pkgconfig"

==> Summary
🍺  /Users/arg/projects/third-party/brew/Cellar/openssl@1.1/1.1.1d: 7,976 files, 17.9MB, built in 4 minutes 38 seconds
==> Installing python dependency: readline
==> Downloading https://homebrew.bintray.com/bottles/readline-8.0.1.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/3c/3c754391e9d243835811d128771ca0f1a565024100fd2c2871534353d46a
######################################################################## 100.0%
==> Pouring readline-8.0.1.mojave.bottle.tar.gz
==> Caveats
readline is keg-only, which means it was not symlinked into /Users/arg/projects/third-party/brew,
because macOS provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.

For compilers to find readline you may need to set:
  export LDFLAGS="-L/Users/arg/projects/third-party/brew/opt/readline/lib"
  export CPPFLAGS="-I/Users/arg/projects/third-party/brew/opt/readline/include"

For pkg-config to find readline you may need to set:
  export PKG_CONFIG_PATH="/Users/arg/projects/third-party/brew/opt/readline/lib/pkgconfig"

==> Summary
🍺  /Users/arg/projects/third-party/brew/Cellar/readline/8.0.1: 48 files, 1.5MB
==> Installing python dependency: sqlite
==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.29.0.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/5f/5f2f8f36a8d13733b0374ac39bdcd32dea10315e7442b9bb9942465487cb
######################################################################## 100.0%
==> Pouring sqlite-3.29.0.mojave.bottle.tar.gz
==> Caveats
sqlite is keg-only, which means it was not symlinked into /Users/arg/projects/third-party/brew,
because macOS provides an older sqlite3.

If you need to have sqlite first in your PATH run:
  echo 'export PATH="/Users/arg/projects/third-party/brew/opt/sqlite/bin:$PATH"' >> ~/.bash_profile

For compilers to find sqlite you may need to set:
  export LDFLAGS="-L/Users/arg/projects/third-party/brew/opt/sqlite/lib"
  export CPPFLAGS="-I/Users/arg/projects/third-party/brew/opt/sqlite/include"

For pkg-config to find sqlite you may need to set:
  export PKG_CONFIG_PATH="/Users/arg/projects/third-party/brew/opt/sqlite/lib/pkgconfig"

==> Summary
🍺  /Users/arg/projects/third-party/brew/Cellar/sqlite/3.29.0: 11 files, 3.9MB
==> Installing python dependency: xz
==> Downloading https://homebrew.bintray.com/bottles/xz-5.2.4.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/01/010667293df282c8bceede3bcd36953dd57c56cef608d09a5b50694ab7d4
######################################################################## 100.0%
==> Pouring xz-5.2.4.mojave.bottle.tar.gz
🍺  /Users/arg/projects/third-party/brew/Cellar/xz/5.2.4: 92 files, 1MB
==> Installing python
==> Downloading https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tar.xz
######################################################################## 100.0%
==> ./configure --prefix=/Users/arg/projects/third-party/brew/Cellar/python/3.7.4_1 --enable-ipv6 --datarootdir
==> make
==> make install PYTHONAPPSDIR=/Users/arg/projects/third-party/brew/Cellar/python/3.7.4_1
==> make frameworkinstallextras PYTHONAPPSDIR=/Users/arg/projects/third-party/brew/Cellar/python/3.7.4_1/share/
==> Downloading https://files.pythonhosted.org/packages/1d/64/a18a487b4391a05b9c7f938b94a16d80305bf0369c6b0b950
######################################################################## 100.0%
==> Downloading https://files.pythonhosted.org/packages/93/ab/f86b61bef7ab14909bd7ec3cd2178feb0a1c86d451bc9bccd
######################################################################## 100.0%
==> Downloading https://files.pythonhosted.org/packages/1d/b0/f478e80aeace42fe251225a86752799174a94314c4a80ebfc
######################################################################## 100.0%
==> /Users/arg/projects/third-party/brew/Cellar/python/3.7.4_1/bin/python3 -s setup.py --no-user-cfg install --
==> /Users/arg/projects/third-party/brew/Cellar/python/3.7.4_1/bin/python3 -s setup.py --no-user-cfg install --
==> /Users/arg/projects/third-party/brew/Cellar/python/3.7.4_1/bin/python3 -s setup.py --no-user-cfg install --
==> Caveats
Python has been installed as
  /Users/arg/projects/third-party/brew/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /Users/arg/projects/third-party/brew/opt/python/libexec/bin

If you need Homebrew's Python 2.7 run
  brew install python@2

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /Users/arg/projects/third-party/brew/lib/python3.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
==> Summary
🍺  /Users/arg/projects/third-party/brew/Cellar/python/3.7.4_1: 8,473 files, 119.3MB, built in 2 minutes 1 second
==> `brew cleanup` has not been run in 30 days, running now...
Pruned 0 symbolic links and 2 directories from /Users/arg/projects/third-party/brew
==> Caveats
==> openssl@1.1
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /Users/arg/projects/third-party/brew/etc/openssl@1.1/certs

and run
  /Users/arg/projects/third-party/brew/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /Users/arg/projects/third-party/brew,
because openssl/libressl is provided by macOS so don't link an incompatible version.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/Users/arg/projects/third-party/brew/opt/openssl@1.1/bin:$PATH"' >> ~/.bash_profile

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/Users/arg/projects/third-party/brew/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/Users/arg/projects/third-party/brew/opt/openssl@1.1/include"

For pkg-config to find openssl@1.1 you may need to set:
  export PKG_CONFIG_PATH="/Users/arg/projects/third-party/brew/opt/openssl@1.1/lib/pkgconfig"

==> readline
readline is keg-only, which means it was not symlinked into /Users/arg/projects/third-party/brew,
because macOS provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.

For compilers to find readline you may need to set:
  export LDFLAGS="-L/Users/arg/projects/third-party/brew/opt/readline/lib"
  export CPPFLAGS="-I/Users/arg/projects/third-party/brew/opt/readline/include"

For pkg-config to find readline you may need to set:
  export PKG_CONFIG_PATH="/Users/arg/projects/third-party/brew/opt/readline/lib/pkgconfig"

==> sqlite
sqlite is keg-only, which means it was not symlinked into /Users/arg/projects/third-party/brew,
because macOS provides an older sqlite3.

If you need to have sqlite first in your PATH run:
  echo 'export PATH="/Users/arg/projects/third-party/brew/opt/sqlite/bin:$PATH"' >> ~/.bash_profile

For compilers to find sqlite you may need to set:
  export LDFLAGS="-L/Users/arg/projects/third-party/brew/opt/sqlite/lib"
  export CPPFLAGS="-I/Users/arg/projects/third-party/brew/opt/sqlite/include"

For pkg-config to find sqlite you may need to set:
  export PKG_CONFIG_PATH="/Users/arg/projects/third-party/brew/opt/sqlite/lib/pkgconfig"

==> python
Python has been installed as
  /Users/arg/projects/third-party/brew/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /Users/arg/projects/third-party/brew/opt/python/libexec/bin

If you need Homebrew's Python 2.7 run
  brew install python@2

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /Users/arg/projects/third-party/brew/lib/python3.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218

Second Real-World Use: Installing Hub

For some reason this happened in the wrong Homebrew.

$ brew install hub
Error: Can't create update lock in /usr/local/var/homebrew/locks!
Fix permissions by running:
  sudo chown -R $(whoami) /usr/local/var/homebrew
Error: The following directories are not writable by your user:
/usr/local/etc/bash_completion.d
/usr/local/share/doc
/usr/local/share/man
/usr/local/share/man/man1
/usr/local/share/man/man5
/usr/local/share/man/man7
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var/homebrew/locks

You should change the ownership of these directories to your user.
  sudo chown -R $(whoami) /usr/local/etc/bash_completion.d /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man5 /usr/local/share/man/man7 /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew/locks

And make sure that your user has write permission.
  chmod u+w /usr/local/etc/bash_completion.d /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man5 /usr/local/share/man/man7 /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew/locks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

I thought maybe I had left a terminal tab open where my PATH was still pointing to the bad systemwide Homebrew. I closed and reopened the tab and got the same thing. Then I checked whether my new Homebrew was in my $PATH:

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
1
2

Update 2019-09-17

I ran into this:

$ brew install pipenv
Error: Can't create update lock in /usr/local/var/homebrew/locks!
Fix permissions by running:
  sudo chown -R $(whoami) /usr/local/var/homebrew
Error: The following directories are not writable by your user:
/usr/local/etc/bash_completion.d
/usr/local/share/doc
/usr/local/share/man
/usr/local/share/man/man1
/usr/local/share/man/man5
/usr/local/share/man/man7
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var/homebrew/locks

You should change the ownership of these directories to your user.
  sudo chown -R $(whoami) /usr/local/etc/bash_completion.d /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man5 /usr/local/share/man/man7 /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew/locks

And make sure that your user has write permission.
  chmod u+w /usr/local/etc/bash_completion.d /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man5 /usr/local/share/man/man7 /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew/locks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

This solved it:

$ source ~/.bashrc 
$ echo $PATH
/Users/arg/projects/third-party/brew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
$ brew install pipenv
1
2
3
4

It turns out ~/.bash_profile is the file to use on Mac OS X Mojave (I have 10.14.6). Not .bashrc. That's why it wasn't working. Problem solved!

Last Updated: 9/18/2019, 3:38:13 PM