How to install homebrew to /usr rather than /usr/local

One way is to modify the install.sh script in homebrew git source and change HOMEBREW_PREFIX to point to whereever you want homebrew to install.

In my case, I've decided to use /usr/local2, because of some restrictions on /usr/local in OSX Catalina, so modify install.sh with HOMEBREW_PREFIX=/usr/local2 and HOMEBREW_REPOSITORY=/usr/local2/Homebrew before running ./install.sh.

Two problems you have to watch:

  1. Some packages insist on installing in /usr/local unless you manually hunt down and modify the source (not trivial)
  2. Installing in a directory that already has similar/equal files can overwrite them and render your system unstable. Especially /usr, where a lot of system commands exist there, which you never want to replace at all.

This is a bad idea if your goal is to be productive and use the tools. But you can learn a ton by disabling SIP on a machine you don’t need and seeing what breaks when you modify the tool. If your goal is to learn, go for it. Here is why it’s “bad” and some very good resources on the history of where to add customizations on unix.

Apple protects /usr via system integrity protection and the closest place to / that’s encouraged to write files is /usr/local

  • https://support.apple.com/en-us/HT204899

Package managers (and the people that write and spend a lot of time using them) can be as passionate (and sometimes prickly) in terms of preference as those debating text editors like [ed|sed|vi|emacs] as well as newer programming editors with more graphical basis.

  • What is standard for OS X filesystem? e.g. /opt/ vs. /usr/
  • Has Unix directory usage or policy changed in High Sierra?
  • Where should I install new (source code) software on a Mac?

This answer particularly has some good thinking and clear discussion as well as the above questions. There would have to be a very compelling basis to diverge from the standard for homebrew even if you didn’t but heads with Apple on SIP in the process (which is what happens in /usr).