More than 3 years have passed since last update.


Last updated at Posted at 2018-10-30







  • brew install
  • brew uninstall


  • brew list


  • brew services list


  • brew doctor


  • brew --config


  • brew update
  • brew upgrade


  • brew info パッケージ名


  • brew switch パッケージ名 バージョン


  • brew cleanup

brew install

  • パッケージをインストールする
$ brew install vim

brew uninstall

  • パッケージをアンインストールする
$ brew uninstall vim

brew list

  • これまで brew install したものを一覧で表示する
$ brew list
autoconf        imagemagick     nodebrew        redis
awscli          jpeg            openssl         ruby
fish            libtiff         perl            sqlite
fontconfig      libtool         phantomjs       tig
freetype        libxml2         pkg-config      vim
gd              libyaml         postgresql      webp
gdbm            mongodb         python          xz
graphviz        mysql           python3         yarn
htop            nkf             rbenv
icu4c           node            readline

brew services list

  • brewのパッケージの起動状況を一覧で表示する
  • started になって入れば無事に起動している状態
$ brew services list
Name              Status  User     Plist
elasticsearch     started ユーザー名 /Users/ユーザー名/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
mongodb           started ユーザー名 /Users/ユーザー名/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
mysql             stopped
postgresql        started ユーザー名 /Users/ユーザー名/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
redis             started ユーザー名 /Users/ユーザー名/Library/LaunchAgents/homebrew.mxcl.redis.plist

brew doctor

  • brew installに関わる諸問題を検出してくれる
$ brew doctor # 実行結果の例

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

brew --config

  • Homebrewに関わるローカルの設定を確認する
$ brew --config
ORIGIN: https://github.com/Homebrew/brew
HEAD: fdd8e9b7cf1e53322492e1e90f685c19bdfde506
Last commit: 9 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: b7bc467b9e1cc8ba4a43cd355d1a6ca16999f0b6
Core tap last commit: 14 hours ago
CPU: quad-core 64-bit kabylake
Homebrew Ruby: 2.3.7 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 10.0 build 1000
Git: 2.17.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
Java: 1.8.0_181
macOS: 10.13.6-x86_64
Xcode: 10.0

brew update


formulae とはHomebrewにおけるビルド方法・手順が書かれたスクリプトのこと

$ brew update
To restore the stashed changes to /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core run:
  'cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core && git stash pop'
Updated 3 taps (homebrew/cask-versions, homebrew/core and homebrew/cask).
==> Updated Formulae
vim asciidoc            bzt                 hugo                ipython             presto        tox                 wireguard-tools
advancemame         beast               circleci            imageworsener       kakoune             pwntools            vips                xmrig
app-engine-java     binutils            fd                  imapfilter          platformio          skafos              whois               youtube-dl

brew upgrade

  • インストールしたパッケージをアップデートしてくれる(更新があるパッケージを再ビルド)
$ brew upgrade awscli
Updating Homebrew...
==> Upgrading 1 outdated package:
awscli 1.14.10 -> 1.16.40
==> Upgrading awscli
==> Downloading https://homebrew.bintray.com/bottles/awscli-1.16.40.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring awscli-1.16.40.high_sierra.bottle.tar.gz
==> Caveats
The "examples" directory has been installed to:

Bash completion has been installed to:

zsh completions and functions have been installed to:
==> Summary
🍺  /usr/local/Cellar/awscli/1.16.40: 4,832 files, 43.9MB

brew info

  • インストールされているパッケージのバージョンなどの情報が知りたいとき
$ brew info nodebrew

brew switch

  • インストールされているツールの複数のバージョンを切り替えたい時
  • brew infoとセットで使えば良い
$ brew info libyaml
libyaml: stable 0.2.1 (bottled)
YAML Parser
/usr/local/Cellar/libyaml/0.1.7 (9 files, 299.8KB) *
  Poured from bottle on 2017-12-18 at 15:54:00
/usr/local/Cellar/libyaml/0.2.1 (9 files, 298.9KB)
  Poured from bottle on 2018-10-26 at 12:32:46
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libyaml.rb
==> Dependencies
Build: autoconf , automake , libtool 
==> Analytics
install: 80,195 (30 days), 252,949 (90 days), 881,478 (365 days)
install_on_request: 24,942 (30 days), 80,537 (90 days), 273,017 (365 days)
build_error: 0 (30 days) # ここのエラーは出ていても動作には大きな影響がない

そんな時にbrew switch:thumbsup:

brew switch libyml 0.1.7 # これで0.1.7が有効になる


※ HOMEBREW_VERSION: 1.8.0時点のフォルダ構成で実行

brew update コマンドでは、
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula ディレクトリに対して、
Homebrewのgithubリポジトリの内容を git pullしてFormulaeというインストールレシピを最新にする模様 :pencil:

※ 紛らわしいけど、Formulae(インストールレシピ)の入ってるディレクトリ名はeの抜けたFormulaなので注意

# homebrew-core/Formulaに移動(lsを叩くとbrewでインストールできるパッケージが並ぶ)
$ cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
$ ls # 以下の一覧は brew installしたいときは、末尾の.rbより前の部分を引数に指定する(brew install libyamlのような形で)
apple-gcc42.rb                       gdb.rb                               libxc.rb                             rogue.rb
appledoc.rb                          gdbm.rb                              libxdg-basedir.rb                    roll.rb
appscale-tools.rb                    gdcm.rb                              libxdiff.rb                          rolldice.rb
apr-util.rb                          gdk-pixbuf.rb                        libxkbcommon.rb                      rom-tools.rb
apr.rb                               gdl.rb                               libxlsxwriter.rb                     root.rb
apt-dater.rb                         gdm.rb                               libxmi.rb                            roswell.rb
aptly-completion.rb                  gdmap.rb                             libxml++.rb                          roundup.rb
aptly.rb                             gdnsd.rb                             libxml++3.rb                         rp.rb
aqbanking.rb                         gdrive.rb                            libxml2.rb                           rpcgen.rb
arabica.rb                           gdub.rb                              libxmlsec1.rb                        rpg.rb
arangodb.rb                          geant4.rb                            libxmp-lite.rb                       rpl.rb
aravis.rb                            gearboy.rb                           libxmp.rb                            rpm.rb
arcade-learning-environment.rb       gearman.rb                           libxo.rb                             rpm2cpio.rb
archey.rb                            gearsystem.rb                        libxslt.rb                           rrdtool.rb
archi-steam-farm.rb                  geckodriver.rb                       libxspf.rb                           rsnapshot.rb
archivemail.rb                       gecode.rb                            libyaml.rb                           rssh.rb
archivemount.rb                      gedit.rb                             libyubikey.rb                        rsstail.rb
argon2.rb                            geeqie.rb                            libzdb.rb                            rst-lint.rb
argp-standalone.rb                   gegl.rb                              libzip.rb                            rswift.rb
argtable.rb                          gem-completion.rb                    libzzip.rb                           rsync-time-backup.rb
argus-clients.rb                     genact.rb                            lifelines.rb                         rsync.rb
argus.rb                             genders.rb                           lightning.rb                         rsyslog.rb
argyll-cms.rb                        generate-json-schema.rb              lighttpd.rb                          rt-audio.rb
aria2.rb                             genext2fs.rb                         lilv.rb                              rtags.rb
ark.rb                               gengetopt.rb                         lincity-ng.rb                        rtf2latex2e.rb
arm-linux-gnueabihf-binutils.rb      genometools.rb                       link-grammar.rb                      rtmidi.rb
armadillo.rb                         genstats.rb                          linkerd.rb                           rtmpdump.rb
armor.rb                             geocode-glib.rb                      linklint.rb                          rtptools.rb
arp-scan.rb                          geogram.rb                           links.rb                             rtv.rb
arp-sk.rb                            geographiclib.rb                     liquibase.rb                         rubberband.rb
arpack.rb                            geoip.rb                             liquid-dsp.rb                        ruby-build.rb
arping.rb                            geoipupdate.rb                       liquidprompt.rb                      ruby-completion.rb
arpoison.rb                          geomview.rb                          liquigraph.rb                        ruby-install.rb
arss.rb                              geos.rb                              little-cms.rb                        ruby.rb
artifactory.rb                       geoserver.rb                         little-cms2.rb                       ruby@1.8.rb
arx-libertatis.rb                    gerbv.rb                             livestreamer.rb                      ruby@2.0.rb
arx.rb                               gerrit-tools.rb                      lldpd.rb                             ruby@2.2.rb
ascii.rb                             get-flash-videos.rb                  llnode.rb                            ruby@2.3.rb
asciidoc.rb                          get_iplayer.rb                       llvm.rb                              runcocoa.rb
asciidoctor.rb                       getdns.rb                            llvm@3.9.rb                          runit.rb
asciidoctorj.rb                      getmail.rb                           llvm@4.rb                            rush.rb
asciinema.rb                         gettext.rb                           llvm@5.rb                            rust.rb
asciiquarium.rb                      getxbook.rb                          llvm@6.rb                            rustc-completion.rb
asciitex.rb                          gexiv2.rb                            lm4tools.rb                          rustup-init.rb
asdf.rb                              gf-complete.rb                       lmdb.rb                              rxvt-unicode.rb
asio.rb                              gflags.rb                            lmod.rb                              ry.rb


brew cleanup

brew は古くなった formula を自動的に消してくれないので、使い続けるほどにインストールしたパッケージが積もってディスクを圧迫する場合があるようです。  
そこで brew cleanup が大活躍です!
Macのお掃除によってストレージ容量が増えて超便利というわけです :relaxed:

$ brew cleanup
Removing: /usr/local/Cellar/awscli/1.14.10... (4,612 files, 41.3MB)
Warning: Skipping fontconfig: most recent version 2.13.1 not installed
Warning: Skipping freetype: most recent version 2.9.1 not installed
Removing: /usr/local/Cellar/gdbm/1.13... (19 files, 553.9KB)
Warning: Skipping htop: most recent version 2.2.0 not installed
Removing: /Users/fuqda/Library/Logs/Homebrew/yarn... (100B)
Removing: /Users/fuqda/Library/Logs/Homebrew/fish... (64B)
Removing: /Users/fuqda/Library/Logs/Homebrew/rbenv... (64B)
==> This operation has freed approximately 1.3GB of disk space.

brew cleanupの注意点:古いformulaが削除されるとマズい場合はやらないこと!

例えば、古いバージョンと新しいバージョンのパッケージを使い分ける必要がある場合に無闇にbrew cleanupすると、古いバージョンのformulaがないために、brew switchでバージョンのswitchが出来なくなるので注意が必要です:sweat:




Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up