How to Download Brew on Mac
Introduction
The command line interface is a not-graphical way to collaborate with your reckoner. Instead of clicking buttons with your mouse, you'll type commands every bit text and receive text-based feedback. The command line, likewise known as a vanquish, lets you lot automate many tasks you lot do on your computer daily, and is an essential tool for software developers.
While the control line interface on macOS has a lot of the functionality you'd find in Linux and other Unix systems, information technology does not ship with a package director. A package director is a collection of software tools that work to automate software installations, configurations, and upgrades. Package managers keep the software they install in a central location and can maintain all software packages on the system in formats that are ordinarily used.
Homebrew is a package manager for macOS which lets you install free and open-source software using your terminal. Y'all'll employ Homebrew to install developer tools like Python, Ruby-red, Node.js, and more.
In this tutorial you'll install and use Homebrew on your Mac. You'll install organization tools and desktop applications from the command line interface.
Prerequisites
You will demand a macOS computer running Catalina or higher with authoritative admission and an cyberspace connection. While older versions of macOS may work, they are not officially supported.
Footstep 1 — Using the macOS Terminal
To access the control line interface on your Mac, you'll use the Terminal application provided by macOS. Like any other application, you lot tin can find information technology by going into Finder, navigating to the Applications
folder, and then into the Utilities
folder. From here, double-click the Terminal awarding to open it up. Alternatively, you can apply Spotlight past property downwards the COMMAND
key and pressing SPACE
to detect Terminal by typing it out in the box that appears.
To go more comfortable using the control line, take a await at [An Introduction to the Linux Terminal] (https://world wide web.digitalocean.com/community/tutorials/an-introduction-to-the-linux-terminal). The control line interface on macOS is very similar, and the concepts in that tutorial are direct applicable.
Now that you have the Concluding running, allow's install some additional tools that Homebrew needs.
Xcode is an integrated development environment (IDE) that is comprised of software development tools for macOS. Y'all won't need Xcode to use Homebrew, merely some of the software and components you'll want to install will rely on Xcode's Control Line Tools parcel.
Execute the post-obit command in the Terminal to download and install these components:
- xcode-select --install
You lot'll be prompted to start the installation, and then prompted again to accept a software license. Then the tools will download and install automatically.
Yous can now install Homebrew.
Step 3 — Installing and Setting Up Homebrew
To install Homebrew, you lot'll download an installation script and so execute the script.
First, download the script to your local car by typing the following control in your Terminal window:
- curl -fsSL -o install.sh https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
The control uses curl
to download the Homebrew installation script from Homebrew's Git repository on GitHub.
Let's walk through the flags that are associated with the roll
command:
- The -
f
or--fail
flag tells the Terminal window to give no HTML document output on server errors. - The
-due south
or--silent
flag mutescurl
and then that information technology does non show the progress meter, and combined with the-S
or--evidence-error
flag it volition ensure thatwhorl
shows an error bulletin if it fails. - The
-L
or--location
flag will tellcurl
to handle redirects. If the server reports that the requested page has moved to a different location, information technology'll automatically execute the request again using the new location. - The
-o
switch specifies a local filename for the file. Rather than displaying the contents to the screen, the-o
switch saves the contents into the file yous specify.
Before running a script you've download from the Cyberspace, you should review its contents so you know what the script volition practise. Use the less
command to review the installation script so you understand what it will do"
- less install.sh
Once you're comfortable with the contents of the script, execute the script with the bash
control:
- /bin/bash install.sh
The installation script volition explicate what it will do and will prompt you to confirm that y'all desire to do it. This lets you know exactly what Homebrew is going to exercise to your organisation before you permit information technology go on. It too ensures yous have the prerequisites in place before it continues.
Y'all'll be prompted to enter your password during the process. However, when you type your countersign, your keystrokes will non display in the Last window. This is a security measure and is something you'll run across often when prompted for passwords on the command line. Even though yous don't run into them, your keystrokes are being recorded by the organisation, so press the RETURN
key once you've entered your countersign.
Press the letter of the alphabet y
for "yes" whenever you are prompted to confirm the installation.
Once the installation procedure is complete, yous will desire to put the directory Homebrew uses to store its executables at the front of the PATH
environment variable. This ensures that Homebrew installations will be called over the tools that macOS includes.
The file you'll modify depends on which beat yous're using. ZSH is the default shell on macOS Mojave and higher. The Fustigate beat out is a pop shell that older versions of macOS used as the default, and if you've upgraded your OS, you may however be using Bash.
Execute the following command to decide your beat:
- echo $0
You'll see either bash
or zsh
.
If yous're using ZSH, you'll open up the file ~/.zshrc
in your editor:
- nano ~/.zshrc
If y'all're using the Bash crush, you'll employ the file ~/.bash_profile
:
- nano ~/.bash_profile
Once the file opens upwards in the Concluding window, add the following lines to the stop of the file:
~/.zshrc
# Add Homebrew'due south executable directory to the front end of the PATH export PATH =/usr/local/bin:$PATH
The first line is a annotate that will help you lot remember what this does if you lot open this file in the future.
To salvage your changes, hold down the CTRL
key and the alphabetic character O
, and when prompted, press the RETURN
key. And then go out the editor by holding the CTRL
cardinal and pressing X
. This will render you to your Terminal prompt.
To activate these changes, close and reopen your Final app. Alternatively, use the source
control to load the file y'all modified.
If y'all modified .zshrc
, execute this command:
- source ~/.zshrc
If you modified .bash_profile
, execute this control:
- source ~/.bash_profile
Once you accept done this, the changes yous have made to the PATH
environment variable will take effect. They'll exist set correctly when you log in again in the future, as the configuration file for your beat out is executed automatically when you lot open the Concluding app.
Now let's verify that Homebrew is set up correctly. Execute this control:
- brew doctor
If no updates are required at this time, yous'll encounter this in your Terminal:
Output
Your system is set to mash.
Otherwise, you lot may get a warning to run some other command such as mash update
to ensure that your installation of Homebrew is up to date. Follow whatsoever on-screen instructions to fix your environment before moving on.
Step 4 — Installing, Upgrading, and Removing Packages
At present that Homebrew is installed, use it to download a bundle. The tree
control lets you lot meet a graphical directory tree and is bachelor via Homebrew.
Install tree
with the brew install
command:
- mash install tree
Homebrew will update its list of packages and and so download and install the tree
control:
Output
Updating Homebrew... ==> Downloading https://homebrew.bintray.com/bottles/tree-one.viii.0.catalina.bottle.tar.gz ######################################################################## 100.0% ==> Pouring tree-1.8.0.catalina.canteen.tar.gz šŗ /usr/local/Cellar/tree/1.viii.0: 8 files, 117.2KB
Homebrew installs files to /usr/local
past default, and so they won't interfere with future macOS updates. Verify that tree
is installed by displaying the command's location with the which
control:
- which tree
The output shows that tree
is located in /usr/local/bin
:
Output
/usr/local/bin/tree
Run the tree
control to see the version:
- tree --version
The version prints to the screen, indicating it's installed:
Output
tree v1.eight.0 (c) 1996 - 2018 past Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro
Occasionally, you'll want to upgrade an existing package. Use the brew upgrade
command, followed by the package proper name:
- brew upgrade tree
You can run mash upgrade
with no boosted arguments to upgrade all programs and packages Homebrew manages.
When y'all install a new version, Homebrew keeps the older version around. Later on a while, you might desire to reclaim deejay space by removing these older copies. Run brew cleanup
to remove all old versions of your Homebrew-managed software.
To remove a bundle you're no longer using, apply brew uninstall
. To uninstall the tree
command, execute this command:
- mash uninstall tree
The output shows that the packet was removed:
Output
Uninstalling /usr/local/Cellar/tree/ane.8.0... (8 files, 117.2KB)
You lot tin use Homebrew to install desktop applications too.
Pace 5 — Installing Desktop Applications
You lot're non restricted to using Homebrew for command-line tools. Homebrew Cask lets you install desktop applications. This feature is included with Homebrew, then there's zip boosted to install.
Test information technology out past using Homebrew to install Visual Studio Code. Execute the post-obit command in your terminal:
- mash install visual-studio-code
The application will install:
Output
==> Downloading https://update.code.visualstudio.com/1.58.2/darwin/stable ==> Downloading from https://az764295.vo.msecnd.net/stable/c3f126316369cd610563c75b1b1725e0679adfb3/VSCode-darwin.zippo ######################################################################## 100.0% ==> Installing Cask visual-studio-code ==> Moving App 'Visual Studio Code.app' to '/Applications/Visual Studio Code.app' ==> Linking Binary 'code' to '/usr/local/bin/code' šŗ visual-studio-code was successfully installed!
You'll find the application in your Applications
folder, just as if y'all'd installed it manually.
To remove it, use brew uninstall
:
- mash uninstall visual-studio-code
Homebrew will remove the installed software:
Output
==> Uninstalling Cask visual-studio-lawmaking ==> Bankroll App 'Visual Studio Code.app' up to '/usr/local/Caskroom/visual-studio-code/1.58.2/Visual Studio Lawmaking.app' ==> Removing App '/Applications/Visual Studio Lawmaking.app' ==> Unlinking Binary '/usr/local/bin/lawmaking' ==> Purging files for version 1.58.two of Cask visual-studio-code
It performs a backup first in case the removal fails, simply once the programme is fully uninstalled, the fill-in is removed every bit well.
Step vi — Uninstalling Homebrew
If you no longer need Homebrew, you can use its uninstall script.
Download the uninstall script with roll
:
- curl -fsSL -o uninstall.sh https://raw.githubusercontent.com/Homebrew/install/main/uninstall.sh
As always, review the contents of the script with the less
control to verify the script's contents:
- less uninstall.sh
One time you've verified the script, execute the script with the --help
flag to see the diverse options you lot can use:
- bash uninstall.sh --help
The options brandish on the screen:
Output
Homebrew Uninstaller Usage: uninstall.sh [options] -p, --path=PATH Sets Homebrew prefix. Defaults to /usr/local. --skip-cache-and-logs Skips removal of HOMEBREW_CACHE and HOMEBREW_LOGS. -f, --force Uninstall without prompting. -q, --repose Suppress all output. -d, --dry-run Simulate uninstall but don't remove anything. -h, --assist Display this message.
Use the -d
flag to run across what the script will do:
- bash uninstall.sh -d
The script will list everything it will delete:
Output
Alarm: This script would remove: /Users/brianhogan/Library/Caches/Homebrew/ /Users/brianhogan/Library/Logs/Homebrew/ /usr/local/Caskroom/ /usr/local/Cellar/ /usr/local/bin/brew -> /usr/local/bin/brew ==> Removing Homebrew installation... Would delete: ....
When y'all're ready to remove everything, execute the script without any flags:
- bash uninstall.sh
This removes Homebrew and any programs yous've installed with it.
Conclusion
In this tutorial you installed and used Homebrew on your Mac. Y'all can now employ Homebrew to install command line tools, programming languages, and other utilities y'all'll demand for software evolution.
Homebrew has many packages you tin can install. Visit the official list to search for your favorite programs.
Comments
Post a Comment