2

I'm wondering if it is possible (and if so, how) to install Homebrew package manager to /usr directory rather than /usr/local directory. I have macOS High Sierra.

6
  • 2
    This is not a good idea. Why? Commented Mar 31, 2020 at 0:14
  • why not? i'm just wondering if it is possible. and so it is more like apt, so i don't notice it. Commented Mar 31, 2020 at 0:15
  • 2
    Homebrew is designed to go in /usr/local, which is the correct place for third-party software. If you upgrade your OS, Apple's security will prohibit (and remove) files in /usr. Going against expected assumptions about file locations will usually cause unforeseen problems. It may be technically possible, but unless you have a strong need for doing this (as distinct from a 'want'), I would advise against it.
    – benwiggy
    Commented Mar 31, 2020 at 10:18
  • @benwiggy I guess you're right. Commented Mar 31, 2020 at 11:05
  • +1 even though my gut check is this is a very bad idea. Let’s see what people think. Is there a benefit you expect to follow by avoiding /usr/local And overloading the parent directory?
    – bmike
    Commented Oct 18, 2020 at 0:56

2 Answers 2

3

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.
2

This is a bad idea if your goal is to be productive and use that tool as designed and documented. But you can learn a ton by disabling SIP on a test machine and seeing what breaks when you modify the tool. If your goal is to learn, go for it. Here is why it’s likely “non-optimal” or “extra work” to force your modifications into /usr 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

Debates about package managers (and the people that write and spend a lot of time using them) can be passionate (and sometimes prickly). Where to store Unix or command line files can be as opinionated in terms of preference as those debating text editors like [ed|sed|vi|emacs|nano|pico] as compared to newer programming editors with more graphical features. Choosing for what you intend to optimize and how you prefer to learn and work is a highly personal choice and not something that is strictly right or wrong.

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).

With the introduction of ARM and Intel tooling to Homebrew, the defaults are now /opt/homebrew and usr/local for brewing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .