<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass[onecolumn,letterpaper,11pt]{article}

%===================================================================
\input{common_latex/common_latex_packages}
\input{common_latex/common_latex_definitions}
\input{common_latex/common_latex_help_format}
%===================================================================

\begin{document}

\begin{labcover}
\labtitle{Help Topic: Installing and Using the Homebrew Package Manager}
\vspace{0.1in}
\labdate{Spring 2025}
\vspace{0.1in}
\labauth{Michael Benjamin, mikerb@mit.edu}
\labauth{Department of Mechanical Engineering}
\labauth{MIT, Cambridge MA 02139}
\labline
\end{labcover}

\wikidoc{file=Help.OSXHomebrew}
\wikidoc{auth=mikerb@mit.edu}

%====================================================================
\section*{Installing and Using the Homebrew Package Manager}
%====================================================================

We will use MacPorts or Homebrew occasionally in this class to install
open source software packages as needed. Both package managers work
perfectly fine for the purposes of 2.680. You do not need both package
managers. If you already have MacPorts installed, you can safely skip
installing Homebrew, and vice-versa.

\vspace{0.1in}
\noindent
Arguably there is greater adoption of Homebrew than MacPorts, and
Homebrew is generally faster to install packages, but both are very
fast in practice. In 2.680 we recommend Homebrew. But if you
would like to use MacPorts, see:

\vspace{0.1in}
\noindent
\urlx{https://oceanai.mit.edu/ivpman/help/osx_get_macports}


\vspace{0.1in}
\noindent
This document describes how to obtain Homebrew and install needed
packages for 2.680.  If you're using a 2025 course-provided computer,
Homebrew and most of the common packages are already installed. This
topic is for someone using their own Mac for the class who may not
have installed either package manager yet.

\vspace{0.1in}
\noindent
*Note: If you have a course computer, with Homebrew already installed,
you still need to augment your shell path as described in the 
Section \var{"Add Homebrew to Your Shell Path}".

\vspace{0.1in}
\noindent
From the \urlx{https://brew.sh} page: Homebrew is the easiest and most
flexible way to install the UNIX tools Apple didnâ€™t include with
MacOS. It can also install software not packaged for your Linux
distribution to your home directory without requiring sudo.


\vspace{0.2in}
\noindent
Note: You need to have installed XCode before Homebrew may be
installed. If you have not installed XCode yet, or if you are not
sure, return to this topic an do so. A direct link is here:

\vspace{0.1in}
\noindent
\urlx{http://oceanai.mit.edu/ivpman/help/osx_get_xcode}.
\vspace{0.1in}

%--------------------------------------------------------------------
\subsection*{Getting the Homebrew base}
\label{sec_homebrew_base}

Homebrew is a package manager that allows you to easily download
software packages needed in our labs. But the package manager itself,
the Homebrew base, first needs to downloaded and installed in the
steps described here.

\vspace{0.2in}
\noindent
(In most Linux distributions, the analogous package manager (apt-get) is 
present with the out-of-the-box Linux installation. Perhaps because many 
Mac users are not developers, the steps of installing XCode and 
a package manager are left as options for developers.)

\vspace{0.2in}
\noindent
Here's how to get Homebrew:

\begin{packed_itemize}[3]
\item Point your web browser to: \urlx{https://brew.sh}. At the very
  top of the page you will see \var{"Installing Homebrew"}:
\end{packed_itemize}

\vspace{0.1in}
\begin{figure}[H]
\centering
\includegraphics[width=0.64\textwidth]{figs_help/homebrew_install.png}
\caption{The Homebrew main page has instructions for obtaining
  Homebrew by cut-and-pasting the text in this window into your MacOS
  Terminal window.}
\label{fig_homebrew_install}
\end{figure}


\begin{packed_itemize}[3]
\item Follow the instructions to cut and paste the text into your terminal
  window and hit enter. 

\item Confirm that installation succeeded by checking that the
  \cmd{brew} command exists in the folder \var{/opt/homebrew/bin}, or
  in the folder \var{/usr/local/bin}.  If not, see a TA.
  
\end{packed_itemize}

\noindent
{\bf Related Mac Note:}
    
\begin{packed_itemize}[3]

\item Around 2022 Apple started selling MacBook laptops with their own
  M1 (and now M2 and M3) chips, instead of the Intel chips they had always
  used. For some reason, on the older Intel computers, homebrew would
  install all of its binaries in \var{/usr/local/bin}.  And on the newer
  Apple M1 and M2 chip machines, homebrew would install binaries in
  \var{/opt/homebrew/bin}. (shrug emoji). You will need to know which case
  is you since this bin path will need to be added to your shell path
  in the steps described below. 

  \item If you're not sure what type of processor you have, you can go
  to the Apple pull-down menu (upper left corner of your screen),
  select \var{"About this Mac"}, which should be the very first
  option. The very first line should describe the Processor. Check if it
  says Intel or M1 (or M2).

\end{packed_itemize}

\vspace{0.1in}
\noindent
Before you do anything else, let's install the \cmd{wget} command. It will come
in handy very soon. Since the \cmd{brew} command is not yet in our shell
path, we'll invoke it with its full path name:

\vspace{0.1in}
\begin{consoleverb}
$ /opt/homebrew/bin/brew install wget 
\end{consoleverb}
\vspace{0.1in}

%--------------------------------------------------------------------
\subsection*{Add Homebrew to Your Shell Path}
\label{sec_brew_path}

Homebrew packages are installed in \var{/opt/homebrew/}, (or
\var{/usr/local/bin} per the above note on this issue). The \cmd{brew}
command line tool should be installed in this bin directory, and you
add it to your shell path. If you're not sure how to augment your
shell path, see:

\vspace{0.1in}
\noindent
\urlx{http://oceanai.mit.edu/ivpman/help/cmdline_augment_shell_path}.

%--------------------------------------------------------------------
\subsection*{Download Packages Needed for our Labs}

Once Homebrew is installed, we need to use the Homebrew package
manager to download and install common open source software packages
used in this course. This part is relatively easy and is all done from
the command line in a terminal window.  Again make sure the \cmd{brew}
command is in your shell path and then:

\begin{consoleverb}
 $ brew install cmake
 $ brew install subversion
 $ brew install wget
 $ brew install libtiff
 $ brew install fltk
\end{consoleverb}

\vspace{0.1in}
\noindent
Or simply:

\vspace{0.1in}
\begin{consoleverb}
 $ brew install cmake subversion wget libtiff fltk
\end{consoleverb}

\vspace{0.1in}

\begin{packed_itemize}[2]
\item Note: Not all of the above packages result in an executable,
  i.e., {\em program}, installed on your machine. Some do, like
  \cmd{cmake}, \cmd{wget}, and \cmd{svn} from the subversion
  package. The others install libraries that other programs need later
  in the course.

\item Hint: The \cmd{brew install} command accepts a {\em list} of
  packages on the command line like the last entry above. This
  obviates the need for re-typing your password each time.

\item Hint: The \cmd{brew list} command, with no arguments, returns a
  list of already installed packages. You may notice a number of
  packages installed that you didn't request. The Homebrew package
  manager will also download dependency packages as-needed, to build
  the ones you did explicitly request.

\item Hint: The \cmd{brew leaves} command, with no arguments, returns
  a list of installed packages that have been explicitly requested, as
  opposed to those that were installed because they were a dependency
  of a requested package.

\end{packed_itemize}

\end{document}

</pre></body></html>