Homebrew is an invaluable package manager for macOS users, providing a simple way to install, upgrade, and manage software packages. One of the unique features of Homebrew is its ability to install newer versions of commands that are already part of macOS, such as curl, git, and Python. This guide will show you how to use Homebrew to upgrade these preinstalled commands.
Upgrading curl
macOS comes with a version of curl preinstalled. However, if you need to use features available only in a newer version, you can use Homebrew to install it:
brew install curl
This command installs the latest version of curl without overwriting the preinstalled one. To use the Homebrew version of curl, you will need to adjust your system’s PATH environment variable or call the command directly from its installation location within the Homebrew directory.
Upgrading git
Just like curl, macOS comes with a version of git preinstalled. To install a newer version of git using Homebrew, you can run:
brew install git
As before, to use the Homebrew-installed version of git, you’ll need to modify your PATH or call the command directly from its Homebrew installation location.
Upgrading Python
As of macOS Catalina, Python 3.9.6 is preinstalled on macOS. However, at the time of writing, the latest stable release of Python available through Homebrew is version 3.11.3. You can install it using the following command:
brew install python
This command will install the latest version of Python available in Homebrew, which as of now is Python 3.11.3. As with curl and git, to use the Homebrew-installed version of Python, you’ll need to modify your PATH or directly call the command from its Homebrew installation location.
Note: Homebrew installs Python 3 under the command python3
to avoid confusion with the system’s Python 2.7. So, if you run python
on an older version of macOS in the Terminal, it will still refer to the system’s Python 2.7, but running python3
will refer to the Homebrew-installed version. On later versions of macOS, the python
command will not be found, rather than be replaced with python3
.
Conclusion
Homebrew provides a streamlined way to upgrade preinstalled macOS commands, allowing you to access newer features without disturbing the system’s original versions. By understanding how to use Homebrew to manage these commands, you can maintain a more modern and versatile development environment on your Mac.