Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

What is the correct way to install Homebrew?

I would like to instal Homebrew, however I get an error saying I have to su or make the current account an admin. As far as I know using an admin account as a go-to account is not the best security practice.

Also note, this is a multi-user environment (I am not the only computer user).

I read that people make an account for Homebrew and set this account to an admin account. Than the account is used only to:

  • install Homebrew,

  • install via Homebrew (for example Node)

  • update via Homebrew

  • etc.

Is this the best practice and if so, will whatever is installed in this way (for example Node) be available to other accounts?

Either way - what would be the correct (step by step) way to install Homebrew?

Thanks for the help!

1 Answer

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

Also note, this is a multi-user environment (I am not the only computer user).

Not a problem, Homebrew by default only install packages on user's local bin directory, not effecting other user account.

Off the top of my head, here're the steps.

  • First install Xcode from Mac AppStore
  • Open Xcode and accept the terms of license.
  • Install Xcode command line tools by this command
xcode-select --install

Now your system should have everything ready for Homebrew; install it with this one command.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

After it's installed, run this command to make sure all is working correctly.

brew doctor

PS: Installing some of the stuffs list above may ask for your admin password; you have to be on admin account to install them. But once it's all done, you can switch back to standard account type, using Homebrew does not require admin right, nor sudo or su.

One last thing

As far as I know using an admin account as a go-to account is not the best security practice.

As far as I remember, this argument is for Windows XP, isn't it?

Thanks for the reply.

In response to your post I have a few additional questions/comments:

Install the X11 environment by downloading it here http://xquartz.macosforge.org/

Why do I need X11? (It's not even mentioned here: http://blog.teamtreehouse.com/install-node-js-npm-mac).

Also, to be honest I haven't even opened Xcode yet, but (although I am not 100%) I think the command line tools have already been auto-installed just by downloading Xcode from the App store.

As far as I know using an admin account as a go-to account is not the best security practice.

As far as I remember, this argument is for Windows XP, isn't it?

I think the administrator as a default account is not considered good practice, because admin accounts have additional privileges (install apps, change settings, edit other users, etc.) that affect the system as a whole.

Homebrew by default only install packages on user's local bin directory, not effecting other user account.

I tried to install Homebrew (on a non-admin account) with the command below, but get the following:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

This script requires the user [username] to be an Administrator. If this
sucks for you then you can install Homebrew in your home directory or however
you please; please refer to our homepage. If you still want to use this script
set your user to be an Administrator in System Preferences or `su' to a
non-root user with Administrator privileges.

Considering I would prefer not to use an admin account, I guess the best solution is to make the account an admin only while installing Homebrew, than demoting it back to a regular account as you suggested.

Do you think changing the user back to a non-admin would affect Homebrew (making it not work properly or not being able to install, update, etc.) ?

William Li
William Li
Courses Plus Student 26,868 Points

Why do I need X11? (It's not even mentioned here: http://blog.teamtreehouse.com/install-node-js-npm-mac).

I am not familiar with this blog post. X11 is a soft dependency for Homebrew, your system are NOT required to have X11 to install Homebrew; however, after you installed Homebrew and run brew doctor, Homebrew will post a warning that your system needs to have X11, I assume certain Homebrew packages do require X11 to run. That's why I list X11 installation during the steps.

Do you think changing the user back to a non-admin would affect Homebrew

No, Homebrew install everything (including brew executable itself) on user-account level, thus any task it performs does not require admin right. Which I think it's a super great thing; because while using Homebrew, the worst thing you can ever do is mess things up on that one user account; the slight disadvantage here is that since Homebrew isn't installed on a system-level, if you switch to different account, Homebrew isn't there, you have to install it again using that one Homebrew install ruby command.