Getting Homebrew Set Up For Non-Admin Account on Your Mac OSX 10.8
One of the things that I absolutely love about Linux is the package manager. It was the thing that took the most getting used to when I switched from Windows, but now that I'm in the habit of apt-getting almost everything I need (especially as a developer) it's hard not to have it on other platforms. This year, I switched my life to Mac and am loving it, but I still miss my package manager.
Enter homebrew, a package management system for Mac. I was suspicious for a while about this solution, since I'm not really comfortable with installing packages that aren't part of a trusted repository.
My friend David convinced me to give it a try and I think the transparency of the system and the degree to which it keeps things nicely isolated soothes most of my concerns.
I run my mac as a non-admin user for day-to-day work. This is a best practice that I think everyone should follow. It did mean that I needed to do things a little bit differently when setting up homebrew if you have a similar setup.
First of all, you need to have sudo setup for your non-admin account.
Next, you'll need to run the install command for homebrew that can be found on the homepage. I won't reproduce it here for security reasons, but it's a Ruby one-liner that you can find in the simple instructions. This needs to be run as an Administrator.
In the terminal, switch to an Admin account:
su Administrator
Now run the one-liner. It will prompt you before it runs and should complete without any problem.
Homebrew installs to /usr/local which a non-Admin user doesn't have write access to. The answer here is to chown the directories that Homebrew uses so that my limited user can write to it. Unfortunately, that's really not an awesome solution because it means that my non-admin user suddenly has write-access to system directories. See this.
The result was that I actually set up a special user homebrew on my machine only for installing homebrew packages. I chowned the directories necessary using the homebrew account:
sudo chown homebrew /usr/local
sudo chown homebrew /usr/local/share/man/man1
sudo chown homebrew /usr/local/share/man
sudo chown homebrew /usr/local/share
sudo chown homebrew /usr/local/include
sudo chown homebrew /usr/local/etc
This seemed to clear up all of the permissions issues.
(I also removed the homebrew user from my login page to keep from cluttering things up.)
Switch to the newly-created homebrew user. Whenever you want to install or configure homebrew, you should open a terminal and change users to that user (or login to that user's desktop*).
su homebrew
Finally, run the command:
brew doctor
This will give you a list of things that might goof up homebrewing. You'll want to try to fix these. The one that was mysterious to me was about the git repository having a suspicious origin (none).
Warning: Suspicious git origin remote found.With a non-standard origin, Homebrew won't pull updates from the main repository.
I googled, but didn't find a lot about it, but I discovered that one of the first things you should do is:
brew update
This will initialize the git repo and that fixes the issue. I also needed to update Xcode and installed the Xcode command line tools.
Now everything seems to be working!
*In particular, I noticed that npm doesn't like to install packages unless I'm actually logged into the homebrew user's desktop.
Enter homebrew, a package management system for Mac. I was suspicious for a while about this solution, since I'm not really comfortable with installing packages that aren't part of a trusted repository.
My friend David convinced me to give it a try and I think the transparency of the system and the degree to which it keeps things nicely isolated soothes most of my concerns.
I run my mac as a non-admin user for day-to-day work. This is a best practice that I think everyone should follow. It did mean that I needed to do things a little bit differently when setting up homebrew if you have a similar setup.
First of all, you need to have sudo setup for your non-admin account.
Next, you'll need to run the install command for homebrew that can be found on the homepage. I won't reproduce it here for security reasons, but it's a Ruby one-liner that you can find in the simple instructions. This needs to be run as an Administrator.
In the terminal, switch to an Admin account:
su Administrator
Now run the one-liner. It will prompt you before it runs and should complete without any problem.
Homebrew installs to /usr/local which a non-Admin user doesn't have write access to. The answer here is to chown the directories that Homebrew uses so that my limited user can write to it. Unfortunately, that's really not an awesome solution because it means that my non-admin user suddenly has write-access to system directories. See this.
The result was that I actually set up a special user homebrew on my machine only for installing homebrew packages. I chowned the directories necessary using the homebrew account:
sudo chown homebrew /usr/local
sudo chown homebrew /usr/local/share/man/man1
sudo chown homebrew /usr/local/share/man
sudo chown homebrew /usr/local/share
sudo chown homebrew /usr/local/include
sudo chown homebrew /usr/local/etc
This seemed to clear up all of the permissions issues.
(I also removed the homebrew user from my login page to keep from cluttering things up.)
Switch to the newly-created homebrew user. Whenever you want to install or configure homebrew, you should open a terminal and change users to that user (or login to that user's desktop*).
su homebrew
Finally, run the command:
brew doctor
This will give you a list of things that might goof up homebrewing. You'll want to try to fix these. The one that was mysterious to me was about the git repository having a suspicious origin (none).
Warning: Suspicious git origin remote found.With a non-standard origin, Homebrew won't pull updates from the main repository.
I googled, but didn't find a lot about it, but I discovered that one of the first things you should do is:
brew update
This will initialize the git repo and that fixes the issue. I also needed to update Xcode and installed the Xcode command line tools.
Now everything seems to be working!
*In particular, I noticed that npm doesn't like to install packages unless I'm actually logged into the homebrew user's desktop.
Comments
Post a Comment