Homebrew is a very usefual package manager that can be installed on the macOS system. It's what I use to manage by Python installations along with my SQL database as well. It has a nice, easy to learn, syntax and is simple to install from the terminal on an Apple computer. What is a package manager you ask? Well join me in the next section and we'll discuss the details behind it.
A package manger is according to Wikipedia "A a collection of software tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer's operating system in a consistent manner." In normal speak its just a program that handles programs on your computer. Instead of having to go to Google to upgrade Chrome, or going to Adobe to upgrade Photoshop, this program takes care of all that leg work and brings the files to you while all you have to do is type a simple command.
The package manager will also keep track of what programs you have installed on your system and what versions of those programs are installed as well. It's a very useful for getting things up and running quickly and effortlessly without having to worry about dealing with source files. If I was powering on a new Macbook or iMac for the first time, Homebrew would be the first program I installed to get the software I need to develop my scripts.
Installing Homebrew is simple and just takes this simple one line command:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Copy and paste that into your terminal and hit enter and that's all you need to do. And now you're on your way to becoming a programmer. You can read more about the Homebrew package manager at the Homebrew website.
If you clicked on the page I linked above you would see that "Homebrew installs packages
to their own directory and then symlinks their files into
/usr/local. Ok, so what
does all that mean? We'll break it down piece by piece. So first Homebrew installs the files
you want in its own file system so they don't contaminate other files of the operating system.
This is especially important for langauges like Ruby and Python where the Mac OS has system
installed versions of these langauges already installed in
/usr/bin. You never want
to touch the versions of these located in that folder as it can affect other programs the OS
But the operating system won't know where these files are located because the directory is
not stored in the OS
$PATH environment variable(If you don't understand what that is
don't worry we'll get there in future tutorials). So to get around that Homebrew creates a symbolic
link to its files and stores those in your
/usr/local/bin which is in the
A symbolic link is basically the same as a shortcut in Windows or Mac where you create an icon on your desktop to point to a file or a directory. However, a symbolic link does a little bit more as it "will make it look like the linked file is actually there, rather than it just being a shortcut." So Homebrew is making it look like the programs are in the bin folder so when we type the commands into terminal they will execute properly.
One last thing I'll touch on quickly is why installing to
/usr back in the olden days was used to store executables and
libraries that were not system critical, and
/usr/local/ was used to store software
that wouldn't be overwritten with a system update i.e. it was installed locally. However that
has changed in recent years with most linuxes symbolic linking
/usr/bin and Apple has
/usr protected as well. By installing into
/usr/local/we avoid accidentally overwritting or messing up files in our
usr/bin that could cause serious issues in the operation of the Mac OS. Again
it's not neccesary to know any of this to get Homebrew to work on your computer so if you don't
I wouldn't worry about it too much.
Homebrew has three basic commands:
brew install [package name]
brew uninstall [package name]
brew upgrade [package name]
These three commands will install new packages, remove old packages you on longer want, and update packages that are out of date. That's it, pretty easy right? There's a lot more to Homebrew than this, but if you want to learn more I suggest checking out the documentation in the link to their site above or the links in the sources I list below.
Homebrew is only available for the MacOS, but if you're on Windows or Linux don't despair. Linux Brew is a package manager for Linux that is a fork of the Homebrew repo so should work in a very similar fashion. For Windows there seems to be Chocolatey that has both a GUI and a command line implementation. I haven't used either of these so I can't attest to how well they work, but if you know something better or have had problems with these please email me firstname.lastname@example.org and let me know.