
Installs, updates and uninstalls using Homebrew or Winget
Table of Contents
Introduction
I’m a Mac user but work in a Windows world, rather than trying to cover commands for both, I thought I’d write a single post and then signpost it in future posts. In this post, I wanted to cover the applications I use to manage tools on both platforms - Homebrew for Mac and Winget for Windows. Both of these tools are package managers that allow you to easily install and manage software on your machine. They are both command-line tools, meaning that it is possible to set up scripts to automate the installation of tools, to help maintain consistency across machines, and to make it easier to set up new machines or new developers.
This post is not intended to be a comprehensive guide to using Homebrew or Winget, but rather an introduction to the tools to help with following along with posts that may require the installation of tools.
What is a Package Manager?
A package manager is a tool that allows you to easily install, update, and manage software on your machine. It typically works by maintaining a repository of software packages, which can be installed with a single command. There are several options on Windows, but Winget being natively available on Windows 10 and above, it’s the most accessible option for most users. On MacOS, Homebrew is the most popular package manager and is widely used in the developer community.
Homebrew
Homebrew is a package manager for MacOS. It allows you to install Formulae (command-line tools) and Casks (GUI applications) with a single command. For example, I can install python by running the command brew install python@3.12 and I can install Obsidian by running the command brew install --cask obsidian. Homebrew retains an inventory of installed packages, making it easy to update or remove them as needed. Grab the command to install Homebrew from the Homebrew website and run it in your terminal to get started.
Finding and installing packages using Homebrew
To find out if a package is available, you can use the brew search command followed by the name of the package you’re looking for. For example, if I wanted to check if Firefox was available, I could run the command brew search firefox and it would return a list of packages that match the search term. If the package is available, it will be listed in the results:
brew search firefox
==> Formulae
firefoxpwa firefly
==> Casks
firefox firefox@cn (disabled) firefox@esr multifirefox (deprecated)
firefox@beta firefox@developer-edition firefox@nightly
Several packages are returned, but probably the one I want is firefox so I can run the command brew install --cask firefox to install it:
brew install firefox --cask
==> Fetching downloads for: firefox
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/284fbc9e51a1104567e8f57f353037a1738d2b26/Casks/f/firefox.rb
############################################################################################################################## 100.0%
✔︎ Cask firefox (150.0.2) Verified 151.3MB/151.3MB
==> Installing Cask firefox
==> Moving App 'Firefox.app' to '/Applications/Firefox.app'
==> Linking Binary 'firefox.wrapper.sh' to '/opt/homebrew/bin/firefox'
🍺 firefox was successfully installed!
The process has pulled the install, moved the app to the Applications folder, and linked the binary to my path so I can run it from the terminal if I want to.
You can use part of the name to search for packages. For example, if I wanted to see what python versions were available, I could run the command brew search python and it would return a list of packages that match the search term:
brew search python
==> Formulae
boost-python3 python-gdbm@3.12 python-tk@3.11 python@3.9 (deprecated)
bpython python-gdbm@3.13 python-tk@3.12 reorder-python-imports
cyclonedx-python python-gdbm@3.14 python-tk@3.13 rustpython
ipython python-launcher python-tk@3.14 tree-sitter-python
libvirt-python python-lsp-server python-tk@3.9 (deprecated) wxpython
micropython python-markdown python-yq pythran
ptpython python-matplotlib python@3.10 cython
python-argcomplete (deprecated) python-packaging ✔ python@3.11 ✔ jython
python-build python-setuptools python@3.12 ✔
python-freethreading python-tabulate python@3.13 ✔
python-gdbm@3.11 python-tk@3.10 python@3.14 ✔
I can then choose the version I want to install, for example, if I wanted to install python 3.13, I could run the command brew install python@3.13 and it would install that specific version of python on my machine.
Reviewing installed packages using Homebrew
To review the packages you have installed, you can use the brew list command. This will return a list of all the packages you have installed on your machine. You can also use the brew info command followed by the name of the package to get more information about it, including the version number and any dependencies it may have.
Updating and removing packages using Homebrew
To update a package, you can use the brew upgrade command followed by the name of the package. For example, if I wanted to update Firefox, I could run the command brew upgrade firefox. If you want to update all of your packages, you can simply run the command brew upgrade without specifying a package name.
To remove a package, you can use the brew uninstall command followed by the name of the package. For example, if I wanted to remove Firefox, I could run the command brew uninstall firefox.
Winget
Winget is a package manager for Windows. It allows you to install software from the command line, making it easier to manage your applications and keep them up to date. Winget is included with Windows 10 and later versions, so you don’t need to install anything to get started.
Finding and installing packages using Winget
To find out if a package is available, you can use the winget search command followed by the name of the package you’re looking for. For example, if I wanted to check if Power BI was available, I could run the command winget search PowerBI and it would return a list of packages that match the search term. If the package is available, it will be listed in the results.
To install a package, you can use the winget install command followed by the name of the package. For example, if I wanted to install Power BI, I could run the command winget install Microsoft.PowerBI and it would install the application on my machine.
Reviewing installed packages using Winget
Similar to Homebrew, you can review the packages you have installed using the winget list command. This will return a list of all the packages you have installed on your machine. You can also use the winget show command followed by the name of the package to get more information about it, including the version number and any dependencies it may have.
Updating and removing packages using Winget
You can run the command winget upgrade to get a list of packages that have updates available. To update a package, you can use the winget upgrade command followed by the name of the package. For example, if I wanted to update Power BI, I could run the command winget upgrade Microsoft.PowerBI and it would update the application on my machine. I can update all of my packages by running the command winget upgrade --all.
To remove a package, you can use the winget uninstall command followed by the name of the package. For example, if I wanted to remove Power BI, I could run the command winget uninstall Microsoft.PowerBI.
Making build scripts using Homebrew and Winget
From here, you can start to build scripts to automate the installation of tools on your machine. One single script could contain all the tools you use regularly, and you can run it whenever you need to set up a new machine or, if you work in a team, you can maintain a central installation script in a repository that everyone can use to set up their machines with the necessary tools for your projects. This can help to maintain consistency across machines and make it easier to onboard new team members.
Wrapping Up
In this post, I covered the basics of using Homebrew and Winget to manage software on your machine. These tools can help you to easily install, update, and manage the applications you use for your projects. By using package managers, you can save time and ensure that you have the necessary tools installed and up to date for your work.
#mtfbwy
Comments