Sudo required for "Untar anywhere" installation method?

Hello, I made several searches but did not find answers to my questions.

I am attempting to install homebrew using the instructions listed on the alternative installation page. I plan to install in /usr/local, as is recommended.

Does making the root homebrew directory and untarring the file require sudo? I have noted that this website strenuously recommends avoiding sudo, but it’s not clear to me whether that also applies to the initial installation of homebrew or only when installing brews.

Is sudo actually required during installation of homebrew?

Thank you in advance.

Only if the hierarchy you’re installing into isn’t writable by you. Stock /usr/local is one of those cases, so the standard Homebrew installer script will use sudo interally to rectify that.

1 Like

Ok great, thanks. I’ll try sudoing the untar and hopefully that will fix it. Not sure if you or anyone reading this has the power to do so, but I think a short note in the installation page that clarifies this would be useful.

That makes the entire Homebrew hierarchy owned by root, which is exactly what you don’t want.

If you’re installing in /usr/local, you should just run the install script, which does the right thing (changes ownerships and permissions with sudo before unpacking). If you’re installing somewhat else, just make sure that the directory you’re unpacking into is owned by you, and untar as you, not as root.

Hmmm, thank you for the clarification. I try to avoid running unknown scripts from the Internet on my machine, particularly ones which request elevated permissions, so the “recommended” installation method is not attractive to me.

I was hoping the alternative installation method would be as simple as simply untaring into usr/local, but it seems that it is not. I really wish there were better instructions on how to install Homebrew in a more security-conscious way.

While that’s generally a wise precaution, it leaves you with the following options if you want to host Homebrew in /usr/local:

  1. Download and inspect the installer script, then run it when you’re satisfied that it doesn’t do anything untoward.
  2. Download and inspect the installer script, then manually replicate its operations.
  3. Make the entire hierarchy owned by you (sudo chown -R $(id -un): /usr/local), then proceed with the alternative install instructions (WARNING: untested).