Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Dev Setup Using Homebrew on OS X

DZone's Guide to

Dev Setup Using Homebrew on OS X

Package managers make installing, updating, and removing items easy. Unfortunately, OS X does not ship with a package manager. Homebrew to the rescue.

· Performance Zone
Free Resource

Transform incident management with machine learning and analytics to help you maintain optimal performance and availability while keeping pace with the growing demands of digital business with this eBook, brought to you in partnership with BMC.

If you’ve ever used apt-get on Ubuntu or Yum, then you are already familiar with package managers. They make installing, updating, and removing items an easy task done from the command line.

Unfortunately, OS X does not ship with a package manager. Homebrew calls itself “The missing package manager for OS X” and couldn’t be more correct.

Why would you want a package manager for OS X? Have you ever tried to set up Apache, MySQL, and PHP locally? Homebrew can help! No more searching for items and downloading them one by one or doing setup manually.

Homebrew Basics

Installation

Before you can install Homebrew you need to have Xcode and its command line tools installed. Xcode can be installed from the App Store.

Xcode’s command line tools can be installed by running xcode-select --install in Terminal.

Once that is done you can install Homebrew with /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)".
To make sure Homebrew installed successfully runbrew --version.

Commands

brew install [package name] installs a new package. Test it out with “wget”.

brew uninstall [package name] removes a new package. Use --force if you have multiple versions of the same package installed and want to remove them all.

brew update updates Homebrew’s list of packages and their versions. It does not update any packages themselves to newer versions.

brew outdated lists all the installed packages that have updates available.

brew upgrade [package name] upgrades the package to the latest version. Omit the package name to upgrade all packages.

brew search allows you to search for packages by name. Useful if you want to see what’s available.

brew doctor checks your system for potential problems... The output will tell you what’s wrong and, usually, how to fix it. It’s good to run this after OS X or Xcode update, after adding/removing packages, or about once a month.

Casks

Homebrew Cask extends Homebrew, adding the ability to manage applications as well as packages.

Add "cask" after brew in (most of) the commands above when working with casks.

For example, "brew cask search chrome" and "brew cask install google-chrome".

By default applications are installed in the ~/Applications directory so applications are only available to the current user. To install applications for all users use the appdir option - e.g. "brew cask install google-chrome --appdir=/Applications".

Bonus: check out Homebrew fonts for easily installing open-source fonts. No more downloading font files and adding them with Font Book.

Computer Setup Script

Setting up a new machine is a pain. Installing applications, setting up configuration, etc. is time-consuming to do manually. Now that we can install packages and applications on the command line, this can be scripted.

Since you are writing a Bash script, you can do other items besides installing packages and applications with Homebrew. For example, I installed Oh My Zsh.

If you need some inspiration or a starting point, thoughtbot has a great laptop setup script. You can also check out my OS X setup script that I used to set up my current machine.

After you write a script, setting up a new machine is a breeze. Start your script, and let Homebrew do the work while you go get a coffee.

Evolve your approach to Application Performance Monitoring by adopting five best practices that are outlined and explored in this e-book, brought to you in partnership with BMC.

Topics:
osx ,homebrew ,package ,package manager

Published at DZone with permission of Emily Miller, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}