`brew list` shows many things I did not install. Why? If something installed depends on them, how do I know?

Viewed 575

On a new machine, I used brew to install only four things: git, node, sqlite and less. Later on, when I ran brew update I was told many other things that I didn't install were "outdated". I ran brew list and got the following:

brotli              less               pcre2
c-ares              libnghttp2         python@3.9
ca-certificates     libuv              readline
gdbm                mpdecimal          sqlite
gettext             ncurses            xz
git                 node
icu4c               openssl@1.1

Where did these come from? If they were installed because git, node or less needs them, how do I find out?

1 Answers

Yes, Homebrew (aka brew), like all package managers, automatically installs dependencies. This is a recursive process: If the dependency itself has dependencies, brew will install them too, and so on.

brew deps

You can see the dependency tree for anything you installed using the brew deps command:

> brew deps node --tree

node
├── brotli
├── c-ares
├── icu4c
├── libnghttp2
├── libuv
├── openssl@1.1
│   └── ca-certificates
└── python@3.9
    ├── gdbm
    ├── mpdecimal
    ├── openssl@1.1
    │   └── ca-certificates
    ├── readline
    ├── sqlite
    │   └── readline
    └── xz

You can see in this tree many of the things you saw in brew list.

brew uses

But to answer your question, you can go in the opposite direction using the brew uses command:

> brew uses readline --installed

node            python@3.9            sqlite

The --installed flag is important, because without it the above command will list everything that uses readline, whether it is installed on your system or not. Notice also how brew uses is recursive (in the opposite direction as brew deps), showing both python@3.9 which uses readline directly, and node, which uses it indirectly.

brew desc

Now if you're curious as to what any of these installed dependencies do, use the brew desc command:

> brew desc pcre2

pcre2: Perl compatible regular expressions library with a new API

brew leaves

By the way, if you just want the short list of what you specifically installed, use brew leaves. Brew keeps track of what you installed so that it can know which things to (recursively) manage for your when you use commands like brew upgrade.

> brew leaves

git
less
node
sqlite
Related