Can I install Homebrew without sudo privileges?
Homebrew nicely allows package installations without sudo privileges, but it seems that I need admin privileges to install Homebrew itself.
I'd like to install Homebrew in a Mac environment where I don't have sudo or admin privileges. Is this possible?
Solution 1:
In case somebody is still looking for this in 2020 and beyond, yes, this is possible without root privileges:
mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
The above allows you to install homebrew anywhere. Make sure that you add homebrew/bin to your $PATH.
More information about this alternative installation method (and source): https://docs.brew.sh/Installation#untar-anywhere
Solution 2:
Yes.
I modified the install script to not use sudo
and to use a directory of your choice. https://gist.github.com/skyl/36563a5be809e54dc139
Download that, set YOUR_HOME
in the script to the absolute path. chmod +x
the script. Create the YOUR_HOME/usr/local
directory. Then, execute the script.
./install.rb
In .bash_profile
, I set (I'm not positive this is important, pretty sure):
export HOMEBREW_PREFIX=/The/path/to/YOUR_HOME/usr/local
Now, I can:
brew install wget
Make sure the bin
directory, YOUR_HOME
+ /usr/local/bin
is on your $PATH
.
which wget
Solution 3:
No.. Unless you do significant surgery.
The reason is that Homebrew strongly insists on installing packages into /usr/local
. In fact, even if you forced it to install somewhere else, you are likely to break dependencies when you use brew install
to install packages. Most if not all of these packages are pre-compiled and linked expecting to live in /usr/local
.
The reason for this insistence is that /usr/local
is precisely where POSIX recommends that stuff like this gets installed. In order to create /usr/local
Homebrew needs temporary admin credentials to create the directory and assign ownership.
This, in turn, is what allows you to install anything else without elevating credentials.