LoginSignup
4
7

More than 3 years have passed since last update.

Homebrew総集編

Last updated at Posted at 2020-01-15

Homebrew

インストール

Terminal
webmaster-patche-no-MacBook-Pro:~ webmaster-patche$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew

Press RETURN to continue or any other key to abort
==> Downloading and installing Homebrew...
remote: Enumerating objects: 181, done.
remote: Counting objects: 100% (181/181), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 282 (delta 178), reused 179 (delta 178), pack-reused 101
Receiving objects: 100% (282/282), 77.69 KiB | 137.00 KiB/s, done.
Resolving deltas: 100% (202/202), completed with 55 local objects.
From https://github.com/Homebrew/brew
   c0b916764..8398d0b2d  master     -> origin/master
HEAD is now at 8398d0b2d Merge pull request #6937 from MikeMcQuaid/bottle_sudo_non_interactive
Updated 1 tap (homebrew/core).
==> New Formulae
ansible@2.8       bandwhich         cobalt            findomain         glow              libb64            poetry
awscurl           cgns              dsvpn             git-filter-repo   komposition       nauty             yaegi
==> Updated Formulae
abcmidi                         fonttools                       mailutils                       prometheus
ack                             fpp                             makedepend                      proteinortho
acpica                          freetds                         man-db                          pstoedit
algernon                        frpc                            mariadb                         puzzles
aliyun-cli                      frps                            mariadb@10.2                    pwntools
alpine                          fselect                         mariadb@10.3                    pyenv
ammonite-repl                   fuse-zip                        mat2                            pyinstaller
angular-cli                     fx                              mawk                            pypy
ansible                         gatsby-cli                      maxwell                         pypy3
ansible-lint                    gcsfuse                         mbedtls                         python-yq
apache-opennlp                  gdb                             mda-lv2                         quickjs
apachetop                       ghq                             mdcat                           ranger
appium                          gimme-aws-creds                 mdds                            rav1e
aptly                           git                             mercurial                       rawtoaces
arangodb                        git-lfs                         mesa                            remind
arduino-cli                     git-plus                        meson                           rex
artifactory                     git-quick-stats                 metaproxy                       rhino
asciinema                       git-remote-hg                   mg                              rocksdb
ask-cli                         git-review                      micropython                     roswell
assimp                          gitbucket                       midnight-commander              rsyslog
astrometry-net                  gitleaks                        mill                            rtv
atdtool                         gitmoji                         miller                          run
atlassian-cli                   gjs                             minio                           rustup-init
aws-cdk                         glassfish                       minio-mc                        s3cmd
aws-elasticbeanstalk            glib-networking                 mitmproxy                       saxon
aws-shell                       global                          mk-configure                    scipy
awscli                          glslang                         mkl-dnn                         serverless
azure-cli                       gmsh                            mmark                           sflowtool
babel                           gnunet                          mpc                             shadowsocks-libev
balena-cli                      gnuradio                        mpd                             shfmt
basex                           go                              mpop                            signal-cli
bcftools                        go@1.12                         mrboom                          silk
bindfs                          godep                           mruby                           singular
bit                             golang-migrate                  multimarkdown                   siril
bitrise                         goreleaser                      multitail                       snapcraft
blast                           gr-osmosdr                      mupdf                           socat
botan                           grep                            mupdf-tools                     sonobuoy
broot                           grin                            mutt                            sourcekitten
caffe                           grin-wallet                     mycli                           sphinx-doc
cake                            groonga                         mydumper                        spin
ccache                          handbrake                       mypy                            starship
cdk                             helmfile                        mysql                           statik
cereal                          helmsman                        mysql@5.6                       stormssh
certbot                         help2man                        mysql@5.7                       streamlink
certigo                         hlint                           nano                            stress-ng
cfn-lint                        homebank                        neo4j                           subversion
chakra                          howdoi                          nethack                         svtplay-dl
choose                          htslib                          netlify-cli                     swagger-codegen
chronograf                      http-server                     nift                            swagger-codegen@2
codemod                         httpie                          node                            swiftformat
cointop                         hugo                            node-build                      swiftlint
collectd                        icecast                         node@10                         syncthing
conan                           ilmbase                         node@12                         synfig
conjure-up                      imagemagick                     nodeenv                         talloc
consul-template                 imagemagick@6                   now-cli                         tarantool
contentful-cli                  imgproxy                        nss                             taskell
convox                          interactive-rebase-tool         ntl                             telegraf
cpl                             internetarchive                 nuget                           teleport
cppad                           istioctl                        numpy                           terraform
cromwell                        jdupes                          nushell                         terragrunt
csvq                            jenkins                         ocrmypdf                        terrahub
ctl                             jfrog-cli-go                    offlineimap                     texmath
ctop                            juju-wait                       okteto                          tintin
curl                            k3d                             onefetch                        tmuxinator
curl-openssl                    kcov                            opa                             tmuxinator-completion
deno                            kepubify                        opencv                          tomee-jax-rs
devspace                        kind                            opencv@2                        tomee-plume
dfmt                            kubeprod                        opencv@3                        topgrade
dhall                           kustomize                       openexr                         tox
dhall-json                      kyma-cli                        openimageio                     trader
distcc                          languagetool                    opensc                          traefik
dmd                             lazygit                         openvdb                         tunnel
docfx                           ldc                             operator-sdk                    twoping
docker-compose                  lego                            osc                             twtxt
docker-credential-helper-ecr    leptonica                       pagmo                           txr
docker-squash                   lerna                           paket                           uhd
doctl                           lftp                            pandoc                          ultralist
dovecot                         libarchive                      pcb                             urh
dub                             libedit                         pcsc-lite                       verilator
duck                            libetonyek                      pdsh                            vim
dune                            libfabric                       peco                            vips
duplicity                       libimagequant                   percol                          visp
easyengine                      liblouis                        perl                            wal2json
ejdb                            libmpdclient                    perltidy                        watch
embree                          libofx                          pgcli                           wcslib
entr                            libopenmpt                      pgweb                           webp
envconsul                       librealsense                    phpmd                           weechat
erlang                          libsixel                        phpmyadmin                      whois
exploitdb                       libtensorflow                   phpstan                         wiggle
fades                           libtorrent-rasterbar            phpunit                         wireguard-tools
fail2ban                        libuv                           picard-tools                    wla-dx
fastlane                        libvirt                         picat                           wtf
faudio                          libvirt-glib                    pipenv                          wxmaxima
fdroidserver                    libvoikko                       pipx                            xdotool
feedgnuplot                     libvterm                        plank                           xmrig
ffsend                          libwebsockets                   pnpm                            xsimd
field3d                         libxkbcommon                    pony-stable                     xtensor
firebase-cli                    libxlsxwriter                   pre-commit                      yamllint
flow                            liquibase                       prestodb                        ykman
fluent-bit                      log4cplus                       primesieve                      yle-dl
fluxctl                         logtalk                         procs                           you-get
fn                              mafft                           proguard                        zsh-autosuggestions
folly                           magic-wormhole                  proj
==> Deleted Formulae
apel              diffuse           leafnode          np2               pygtksourceview   terminator        zim
auto-scaling      globus-toolkit    libagar           pygobject         qriollo           trr
aws-elasticache   hg-flow           mysql-utilities   pygtk             redo              uberftp
aws-sns-cli       ipython@5         node@8            pygtkglext        srclib            vte
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
==> Next steps:
- Run `brew help` to get started
- Further documentation: 
    https://docs.brew.sh

バージョンの確認

Terminal
webmaster-patche-no-MacBook-Pro:~ webmaster-patche$ brew -v
Homebrew 2.2.2
Homebrew/homebrew-core (git revision f246; last commit 2020-01-14)

使い方

brew [--version | -v]

Terminal
$ brew -v
Homebrew 2.2.2
Homebrew/homebrew-core (git revision f246; last commit 2020-01-14)
Homebrew/homebrew-cask (git revision 7585; last commit 2020-01-15)

$ brew --version
Homebrew 2.2.2
Homebrew/homebrew-core (git revision f246; last commit 2020-01-14)
Homebrew/homebrew-cask (git revision 7585; last commit 2020-01-15)

brew command [--verbose | -v] [options] [formula]…

command

  • install / uninstall / list / search コマンドは必須コマンドとして他のコマンドとは異なる
install formula
  • フォーミュラ(パッケージ名)をインストールします
  • --verbose / --debug:デバッグ情報を出力
Terminal
brew install %formula%
uninstall formula
  • フォーミュラ(パッケージ名)をアンインストールします
Terminal
brew uninstall %formula%
list
  • インストール済みのフォーミュラ(パッケージ名)をリスト出力します
Terminal
$ brew list
search (text|/text/)
  • テキストを使用してフォーミュラ(パッケージ名)を部分検索します
  • スラッシュで挟まれている場合は正規表現として解釈する
  • 検索する文字列はオンライン上でhomebrew / coreとhomebrew / caskによって行われる

  • 参考になった技術まとめ

analytics [subcommand]
  • 用途調査中

    • on / off:Homebrewの分析をオンオフにする
    • state:現在の匿名ユーザーの行動分析状態を表示、Analytics参照
    • regenerate-uuid:Homebrewの分析で使用されるUUIDを再生成
cat formula
  • フォーミュラ(パッケージ名)のソースを表示
cleanup [options] [formula|cask]
  • すべてのフォーミュラ(パッケージ名)とcaskの、古いロックファイルと古いダウンロードを削除し、インストールされたフォーミュラ(パッケージ名)の古いバージョンを削除

    • --prune:指定された日より古いすべてのキャッシュファイルを削除する。
    • -n / --dry-run:削除されるものを表示するだけで、実処理は行わない。(デバッグ実行)
    • -s:最新バージョンのダウンロードも含め、キャッシュをスクラブする。インストールのためにダウンロードされたフォーミュラ(パッケージ名)や caskは削除されない。削除したい場合: rm -rf "$(brew --cache)" を行う
    • --prune-prefix:プレフィックスからシンボリックリンクとディレクトリのみを削除し、他のファイルを削除しません。
    • command | cmd:brew cmdを呼び出すときに使用されているファイルへのパスを表示します。
Terminal
$ brew cleanup --dry-run
$
commands [options]
  • 組み込みコマンドと外部コマンド( command項目を参照 )の一覧を表示する
    • -q、-quiet:カテゴリヘッダーのない(組み込みコマンド、外部コマンドなど)コマンドの名前のみを一覧表示
    • --include-aliases:内部コマンドのエイリアスを含める(-qオプションなしでは指定不可)
Terminal
$ brew commands
==> Built-in commands
--cache          cask             desc             info             missing          search           tap-pin          update
--cellar         cat              diy              install          options          sh               tap-unpin        update-report
--env            cleanup          doctor           leaves           outdated         shellenv         uninstall        update-reset
--prefix         command          fetch            link             pin              style            unlink           upgrade
--repository     commands         gist-logs        list             postinstall      switch           unpack           uses
--version        config           help             log              readall          tap              unpin            vendor-install
analytics        deps             home             migrate          reinstall        tap-info         untap

==> Built-in developer commands
audit                  create                 install-bundler-gems   mirror                 ruby                   update-test
bottle                 edit                   irb                    prof                   tap-new                vendor-gems
bump-formula-pr        extract                linkage                pull                   test
bump-revision          formula                man                    release-notes          tests

==> External commands
aspell-dictionaries                           postgresql-upgrade-database                   services

$ brew commands --include-aliases
Error: `include_aliases` cannot be passed without `quiet`.

$ brew commands -q --include-aliases
--cache                           create                            ln                                style
--cellar                          deps                              log                               switch
--config                          desc                              ls                                tap
--env                             diy                               man                               tap-info
--prefix                          doctor                            migrate                           tap-new
--repo                            dr                                mirror                            tap-pin
--repository                      edit                              missing                           tap-unpin
--version                         environment                       options                           test
-S                                extract                           outdated                          tests
-v                                fetch                             pin                               uninstal
abv                               formula                           postgresql-upgrade-database       uninstall
analytics                         gist-logs                         postinstall                       unlink
aspell-dictionaries               help                              prof                              unpack
audit                             home                              pull                              unpin
bottle                            homepage                          readall                           untap
bump-formula-pr                   info                              reinstall                         up
bump-revision                     instal                            release-notes                     update
cask                              install                           remove                            update-report
cat                               install-bundler-gems              rm                                update-reset
cleanup                           irb                               ruby                              update-test
command                           leaves                            search                            upgrade
commands                          link                              services                          uses
config                            linkage                           sh                                vendor-gems
configure                         list                              shellenv                          vendor-install
config
  • Homebrewとシステム構成情報を表示してくれる
  • バグレポートを提出する場合、この情報を提供する必要がある(Homebrewへの情報提供の場合)
Terminal
$ brew --config
HOMEBREW_VERSION: 2.2.2
ORIGIN: https://github.com/Homebrew/brew
HEAD: 13f508d0dc8ada1726ee09a750285d7447ac3df4
Last commit: 3 weeks ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: f2463cbba086689c872cddd3a8bc242976a603ff
Core tap last commit: 20 hours ago
HOMEBREW_PREFIX: /usr/local
CPU: octa-core 64-bit ivybridge
Homebrew Ruby: 2.6.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/bin/ruby
Clang: 10.0 build 1001
Git: 2.20.1 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
macOS: 10.14.6-x86_64
CLT: 10.3.0.0.1.1562985497
Xcode: N/A

$ brew config
HOMEBREW_VERSION: 2.2.2
ORIGIN: https://github.com/Homebrew/brew
HEAD: 13f508d0dc8ada1726ee09a750285d7447ac3df4
Last commit: 3 weeks ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: f2463cbba086689c872cddd3a8bc242976a603ff
Core tap last commit: 20 hours ago
HOMEBREW_PREFIX: /usr/local
CPU: octa-core 64-bit ivybridge
Homebrew Ruby: 2.6.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/bin/ruby
Clang: 10.0 build 1001
Git: 2.20.1 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
macOS: 10.14.6-x86_64
CLT: 10.3.0.0.1.1562985497
Xcode: N/A
deps [options] [formula]
  • フォーミュラ(パッケージ名)の依存関係を表示

    • -n:依存関係をトポロジー順にソートします。
    • --1:再帰ではなく、1レベル下の依存関係のみを表示します。
    • --union:交点ではなく、複数のフォーミュラ(パッケージ名)の依存関係の和集合を表示します。
    • --full-name:依存関係をフルネームでリストします。
    • --include-build:インクルード:フォーミュラ(パッケージ名)のビルド依存関係。
    • --include-optional:Include:フォーミュラ(パッケージ名)のオプションの依存関係。
    • --include-test:フォーミュラ(パッケージ名)の:test依存関係を含めます(非再帰的)。
    • --skip-recommended:フォーミュラ(パッケージ名)の推奨依存関係をスキップします。
    • --include-requirements:フォーミュラ(パッケージ名)の依存関係に加えて要件を含めます。
    • --tree:依存関係をツリーとして表示します。複数のフォーミュラ(パッケージ名)引数を指定した場合、各フォーミュラ(パッケージ名)の個別のツリーを表示します。
    • --annotate:ビルド、テスト、オプション、または推奨される依存関係を出力でマークします。
    • --installed:現在インストールされているフォーミュラ(パッケージ名)の依存関係を一覧表示します。フォーミュラ(パッケージ名)が指定されている場合、現在インストールされている依存関係のみをリストします。
    • --all:使用可能なすべての式の依存関係を一覧表示します。
    • --for-each:--allオプションで使用されるモードに切り替えますが、指定された各式の依存関係のみをリストします(1行に1つの式)。これは、-installed / -all表示モードのデバッグに使用されます。
Terminal
$ brew deps vim
gdbm
libyaml
openssl
perl
python
readline
ruby
sqlite
xz
desc options
  • フォーミュラ(パッケージ名)の名称と説明を表示する
  • なお表示する説明はキャッシュされ、後から表示したものに比べて検索速度が遅くなる(キャッシュが古くなる為)

    • -s、-search:テキストの名前と説明の両方を検索します。テキストがスラッシュで挟まれている場合、それは正規表現として解釈されます。
    • -n、--name:テキストの名前だけを検索します。テキストがスラッシュで挟まれている場合、それは正規表現として解釈されます。
    • -d、-description:テキストの説明だけを検索します。テキストがスラッシュで挟まれている場合、それは正規表現として解釈されます。
    • diy [オプション]:非Homebrewソフトウェアのインストールプレフィックスを自動的に決定します。このコマンドの出力を使用して、独自のソフトウェアをセラーにインストールしてから、brewリンクを使用してHomebrewのプレフィックスにリンクできます。
    • --name:インストールするパッケージの名前を明示的に設定します。
    • --version:インストールするパッケージのバージョンを明示的に設定します。
doctor [options]
  • システムに潜在的な問題がないか確認する
  • 潜在的な問題が見つかった場合、ゼロ以外のステータスで終了
Terminal
$ brew doctor
Your system is ready to brew.

$ echo $?
0
# -> エラーがある場合、異常終了すると思われる
upgrade [options]
  • Homebrew のパッケージの更新(サブコマンド
  • 30日以上古いものが自動削除される
  • 自動削除を止めたければ、環境変数 env HOMEBREW_INSTALL_CLEANUP=1 で止める
Terminal
# デフォルト(30日以上古いものを自動削除)
$ brew upgrade

# 自動削除しない場合
$ env HOMEBREW_INSTALL_CLEANUP=1 brew upgrade
update
  • deplicated

拡張機能

Homebrew cask

インストール

Terminal
$ brew cask
==> Tapping homebrew/cask
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'...
remote: Enumerating objects: 3624, done.
remote: Counting objects: 100% (3624/3624), done.
remote: Compressing objects: 100% (3616/3616), done.
remote: Total 3624 (delta 25), reused 545 (delta 6), pack-reused 0
Receiving objects: 100% (3624/3624), 1.22 MiB | 1.49 MiB/s, done.
Resolving deltas: 100% (25/25), done.
Checking out files: 100% (3604/3604), done.
Tapped 1 command and 3512 casks (3,629 files, 3.9MB).
Homebrew Cask provides a friendly CLI workflow for the administration
of macOS applications distributed as binaries.

Commands:

    --cache    display the file used to cache the Cask
    audit      verifies installability of Casks
    cat        dump raw source of the given Cask to the standard output
    create     creates the given Cask and opens it in an editor
    doctor     checks for configuration issues
    edit       edits the given Cask
    fetch      downloads remote application files to local cache
    home       opens the homepage of the given Cask
    info       displays information about the given Cask
    install    installs the given Cask
    list       with no args, lists installed Casks; given installed Casks, lists staged files
    outdated   list the outdated installed Casks
    reinstall  reinstalls the given Cask
    style      checks Cask style using RuboCop
    uninstall  uninstalls the given Cask
    upgrade    upgrades all outdated casks
    zap        zaps all files associated with the given Cask

See also "man brew-cask"

使い方

  • インストール時に表示されるCommandsを参照
cask [subcommand]
  • install [cask]
    • cask をインストールします
Terminal
$ brew cask install google-chrome

Homebrew services

インストール

Terminal
$ brew services list
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 14 (delta 0), reused 7 (delta 0), pack-reused 0
Unpacking objects: 100% (14/14), done.
Tapped 1 command (43 files, 59.4KB).
Warning: No services available to control with `brew services`

これで自動で tap されて brew services が使用可能な状態になります

Terminal
$ brew services list
Name      Status  User Plist
mysql@5.7 stopped      

使い方

  • services list

    • serviceの一覧を表示
  • services start formula

    • フォーミュラ(パッケージ名) を開始、かつ、ログイン時に起動する設定をする
  • services stop formula

    • フォーミュラ(パッケージ名) を停止、かつ、ログイン時に起動する設定を消す
  • services restart formula

    • フォーミュラ(パッケージ名) でstop; startを実行
Terminal
$ brew services start mysql@5.7
==> Successfully started `mysql@5.7` (label: homebrew.mxcl.mysql@5.7)

最後に

  • brewのバージョンアップデートや拡張機能で変化が激しい為、このまとめは随時編集されます
4
7
0

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
4
7