1. はじめに
私たけるは、元々Linux使いであり、Macでも同じようにパッケージ管理ができないかを探ってきました。MacPortsと比較してこちらの方が使い勝手が良さそうなので、長年Homebrewを使用しております。
また、これまで使用してきたMac mini ServerにはmacOS Serverをインストールしております。しかしながら、macOS MojaveよりmacOS Serverのオープンソースパッケージサービス群が廃止となったことに伴い、自分でパッケージを用意しなければならなくなりました。このサービスのパッケージ管理においても、Homebrewは大きな力を発揮することになるでしょう。
今回購入したMac miniにもこれまで同様Homebrewをインストールしていくことにいたします。
2. 目次
1. はじめに
2. 目次
3. Homebrewとは
4. Homebrewのインストール
4.1. インストール準備
4.2. Homebrewのインストール
4.3. Homebrew Caskのインストール
4.4. mas-cliのインストール
5. パッケージマネージャの使用
5.1. ヘルプの表示
5.2. 診断
5.3. パッケージの検索
5.4. パッケージのインストール
5.5. インストール済みパッケージの確認
5.6. パッケージのアンインストール
5.7. アップデートがあるパッケージ一覧
5.8. パッケージのアップデート
5.9. 同一パッケージのバージョン整理
6. 環境移行
6.1 Brewfileの生成
6.2 Brewfileからパッケージをインストール
7. 参考サイト
3. Homebrewとは
「Mac OS Xオペレーティングシステム上でソフトウェアの導入を単純化するパッケージ管理システムのひとつである」 Wikipediaより
MacPortsと同様の目的と機能を備えつつも、コンパイル時のライブラリは極力システムの物を使おうとするため、リソース消費を最小限に抑えることが可能となります。
使用感はLinuxのDebian系で採用されているaptに近いです。
Max Howellによって開発されました。
4. Homebrewのインストール
4.1. インストール準備
Homebrewはバイナリパッケージのインストールだけを行うのではなく、コンパイルも実施されることが多々あります。それは前述の通り、なるべくシステムのライブラリを使用しようとするためです。その際、Xcodeを利用してコンパイルが実施されますが、App Storeからインストールするととても大きなパッケージになるため、時間も消費する容量も膨大となります。
そこで、Xcodeのコマンドラインツールのみインストールを実施いたします。
ターミナルを起動し、下記の実行します。
$ xcode-select --install
ここで、「インストール」を押します。
すると、使用許諾契約内容が表示されます。
これに同意します。
インストールが完了すると以下のようになるので完了ボタンを押します。
4.2. Homebrewのインストール
ターミナルにて以下のコマンドを実行してください。
インストールが開始されます。
$ /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
==> The following new directories will be created:
/usr/local/bin
/usr/local/etc
/usr/local/include
/usr/local/lib
/usr/local/sbin
/usr/local/share
/usr/local/var
/usr/local/opt
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var/homebrew
/usr/local/var/homebrew/linked
/usr/local/Cellar
/usr/local/Caskroom
/usr/local/Homebrew
/usr/local/Frameworks
Press RETURN to continue or any other key to abort
前半部分はインストールするスクリプトの内容、後半部分はHomeBrew用に作成するディレクトリ一覧ですね。このままEnterキーを押して先に進みます。
==> /usr/bin/sudo /bin/mkdir -p /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
Password:
ディレクトリを作成しようとしますが、/userにディレクトリを作成する際に管理者権限(現在ログインしている)ユーザのパスワードを求められるので入力してください。
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /bin/chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
==> /usr/bin/sudo /usr/sbin/chown takerulocal /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /bin/mkdir -p /Users/takerulocal/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/takerulocal/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown takerulocal /Users/takerulocal/Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Enumerating objects: 125670, done.
Receiving objects: 64% (80429/125670), 24.93 MiB | 2.64 MiB/s
必要なスクリプトをダウンロードしてくれます。
remote: Enumerating objects: 125670, done.
remote: Total 125670 (delta 0), reused 0 (delta 0), pack-reused 125670
Receiving objects: 100% (125670/125670), 29.80 MiB | 1.91 MiB/s, done.
Resolving deltas: 100% (92120/92120), done.
From https://github.com/Homebrew/brew
* [new branch] master -> origin/master
* [new tag] 0.1 -> 0.1
* [new tag] 0.2 -> 0.2
* [new tag] 0.3 -> 0.3
* [new tag] 0.4 -> 0.4
* [new tag] 0.5 -> 0.5
* [new tag] 0.6 -> 0.6
* [new tag] 0.7 -> 0.7
* [new tag] 0.7.1 -> 0.7.1
* [new tag] 0.8 -> 0.8
* [new tag] 0.8.1 -> 0.8.1
* [new tag] 0.9 -> 0.9
* [new tag] 0.9.1 -> 0.9.1
* [new tag] 0.9.2 -> 0.9.2
* [new tag] 0.9.3 -> 0.9.3
* [new tag] 0.9.4 -> 0.9.4
* [new tag] 0.9.5 -> 0.9.5
* [new tag] 0.9.8 -> 0.9.8
* [new tag] 0.9.9 -> 0.9.9
* [new tag] 1.0.0 -> 1.0.0
* [new tag] 1.0.1 -> 1.0.1
* [new tag] 1.0.2 -> 1.0.2
* [new tag] 1.0.3 -> 1.0.3
* [new tag] 1.0.4 -> 1.0.4
* [new tag] 1.0.5 -> 1.0.5
* [new tag] 1.0.6 -> 1.0.6
* [new tag] 1.0.7 -> 1.0.7
* [new tag] 1.0.8 -> 1.0.8
* [new tag] 1.0.9 -> 1.0.9
* [new tag] 1.1.0 -> 1.1.0
* [new tag] 1.1.1 -> 1.1.1
* [new tag] 1.1.10 -> 1.1.10
* [new tag] 1.1.11 -> 1.1.11
* [new tag] 1.1.12 -> 1.1.12
* [new tag] 1.1.13 -> 1.1.13
* [new tag] 1.1.2 -> 1.1.2
* [new tag] 1.1.3 -> 1.1.3
* [new tag] 1.1.4 -> 1.1.4
* [new tag] 1.1.5 -> 1.1.5
* [new tag] 1.1.6 -> 1.1.6
* [new tag] 1.1.7 -> 1.1.7
* [new tag] 1.1.8 -> 1.1.8
* [new tag] 1.1.9 -> 1.1.9
* [new tag] 1.2.0 -> 1.2.0
* [new tag] 1.2.1 -> 1.2.1
* [new tag] 1.2.2 -> 1.2.2
* [new tag] 1.2.3 -> 1.2.3
* [new tag] 1.2.4 -> 1.2.4
* [new tag] 1.2.5 -> 1.2.5
* [new tag] 1.2.6 -> 1.2.6
* [new tag] 1.3.0 -> 1.3.0
* [new tag] 1.3.1 -> 1.3.1
* [new tag] 1.3.2 -> 1.3.2
* [new tag] 1.3.3 -> 1.3.3
* [new tag] 1.3.4 -> 1.3.4
* [new tag] 1.3.5 -> 1.3.5
* [new tag] 1.3.6 -> 1.3.6
* [new tag] 1.3.7 -> 1.3.7
* [new tag] 1.3.8 -> 1.3.8
* [new tag] 1.3.9 -> 1.3.9
* [new tag] 1.4.0 -> 1.4.0
* [new tag] 1.4.1 -> 1.4.1
* [new tag] 1.4.2 -> 1.4.2
* [new tag] 1.4.3 -> 1.4.3
* [new tag] 1.5.0 -> 1.5.0
* [new tag] 1.5.1 -> 1.5.1
* [new tag] 1.5.10 -> 1.5.10
* [new tag] 1.5.11 -> 1.5.11
* [new tag] 1.5.12 -> 1.5.12
* [new tag] 1.5.13 -> 1.5.13
* [new tag] 1.5.14 -> 1.5.14
* [new tag] 1.5.2 -> 1.5.2
* [new tag] 1.5.3 -> 1.5.3
* [new tag] 1.5.4 -> 1.5.4
* [new tag] 1.5.5 -> 1.5.5
* [new tag] 1.5.6 -> 1.5.6
* [new tag] 1.5.7 -> 1.5.7
* [new tag] 1.5.8 -> 1.5.8
* [new tag] 1.5.9 -> 1.5.9
* [new tag] 1.6.0 -> 1.6.0
* [new tag] 1.6.1 -> 1.6.1
* [new tag] 1.6.10 -> 1.6.10
* [new tag] 1.6.11 -> 1.6.11
* [new tag] 1.6.12 -> 1.6.12
* [new tag] 1.6.13 -> 1.6.13
* [new tag] 1.6.14 -> 1.6.14
* [new tag] 1.6.15 -> 1.6.15
* [new tag] 1.6.16 -> 1.6.16
* [new tag] 1.6.17 -> 1.6.17
* [new tag] 1.6.2 -> 1.6.2
* [new tag] 1.6.3 -> 1.6.3
* [new tag] 1.6.4 -> 1.6.4
* [new tag] 1.6.5 -> 1.6.5
* [new tag] 1.6.6 -> 1.6.6
* [new tag] 1.6.7 -> 1.6.7
* [new tag] 1.6.8 -> 1.6.8
* [new tag] 1.6.9 -> 1.6.9
* [new tag] 1.7.0 -> 1.7.0
* [new tag] 1.7.1 -> 1.7.1
* [new tag] 1.7.2 -> 1.7.2
* [new tag] 1.7.3 -> 1.7.3
* [new tag] 1.7.4 -> 1.7.4
* [new tag] 1.7.5 -> 1.7.5
* [new tag] 1.7.6 -> 1.7.6
* [new tag] 1.7.7 -> 1.7.7
* [new tag] 1.8.0 -> 1.8.0
* [new tag] 1.8.1 -> 1.8.1
* [new tag] 1.8.2 -> 1.8.2
* [new tag] 1.8.3 -> 1.8.3
* [new tag] 1.8.4 -> 1.8.4
* [new tag] 1.8.5 -> 1.8.5
* [new tag] 1.8.6 -> 1.8.6
* [new tag] 1.9.0 -> 1.9.0
* [new tag] 1.9.1 -> 1.9.1
* [new tag] 1.9.2 -> 1.9.2
* [new tag] 1.9.3 -> 1.9.3
* [new tag] 2.0.0 -> 2.0.0
* [new tag] 2.0.1 -> 2.0.1
* [new tag] 2.0.2 -> 2.0.2
* [new tag] 2.0.3 -> 2.0.3
* [new tag] 2.0.4 -> 2.0.4
* [new tag] 2.0.5 -> 2.0.5
* [new tag] 2.0.6 -> 2.0.6
* [new tag] 2.1.0 -> 2.1.0
* [new tag] 2.1.1 -> 2.1.1
* [new tag] 2.1.10 -> 2.1.10
* [new tag] 2.1.11 -> 2.1.11
* [new tag] 2.1.2 -> 2.1.2
* [new tag] 2.1.3 -> 2.1.3
* [new tag] 2.1.4 -> 2.1.4
* [new tag] 2.1.5 -> 2.1.5
* [new tag] 2.1.6 -> 2.1.6
* [new tag] 2.1.7 -> 2.1.7
* [new tag] 2.1.8 -> 2.1.8
* [new tag] 2.1.9 -> 2.1.9
HEAD is now at 37714b5ce Merge pull request #6400 from lembacon/virtualenv-16.7.4
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 5044, done.
remote: Counting objects: 100% (5044/5044), done.
remote: Compressing objects: 100% (4842/4842), done.
remote: Total 5044 (delta 49), reused 604 (delta 11), pack-reused 0
Receiving objects: 100% (5044/5044), 4.03 MiB | 1.26 MiB/s, done.
Resolving deltas: 100% (49/49), done.
Tapped 2 commands and 4832 formulae (5,087 files, 12.5MB).
Already up-to-date.
==> 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:which ruby
/usr/bin/ruby
ここで、前半部分はHomeBrewのGitに置けるバージョンの確認を行なっています。
後半部分で最新版のインストールを実施します。
4.3. Homebrew Caskのインストール
Caskを利用することで、ChromeやFirefoxなどのmasOSのGUIアプリケーションをインストール、管理することができるようになります。
CaskのおかげでHomebrewで管理下におけるアプリケーションの数を格段に増やすことができます。
ChromeやFirefox以外のブラウザであるOpere, BraveなどもCaskを使ってインストールすることができます。
Homebrew Caskは Homebrewに含まれるのでインストール不要です。
4.4. mas-cli のインストール
mas-cliは、macOSでコマンドラインからMac App Storeを操作して、インストール済みアプリの更新管理などをウィンドウを切り替えることなくそのまま実行可能にするツールです。
ターミナルにて以下を実行します。
$ brew install mas
実行すると、以下のように進みます。
==> Downloading https://homebrew.bintray.com/bottles/mas-1.6.3.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/3d/3dd5a50b551a37c164c31375cc8498ba870e29e50086bd5c4c294bc26708a6d2?__gda__=exp=15
######################################################################## 100.0%
==> Pouring mas-1.6.3.mojave.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary
🍺 /usr/local/Cellar/mas/1.6.3: 40 files, 11.5MB
これでインストールは完了です。
5. パッケージマネージャの使用
では、実際にパッケージマネージャを利用していきましょう。
パッケージマネージャはbrewというコマンドを用いて管理していきます。
コマンドの形態は以下のようになっています。
5.1. ヘルプの表示
brewのヘルプは以下のコマンドで表示されます。
$ brew help
Example usage:
brew search [TEXT|/REGEX/]
brew info [FORMULA...]
brew install FORMULA...
brew update
brew upgrade [FORMULA...]
brew uninstall FORMULA...
brew list [FORMULA...]
Troubleshooting:
brew config
brew doctor
brew install --verbose --debug FORMULA
Contributing:
brew create [URL [--no-fetch]]
brew edit [FORMULA...]
Further help:
brew commands
brew help [COMMAND]
man brew
https://docs.brew.sh
ここで注意すべきなのが、このhelpで表示されたコマンドは全てではないということです。
例えば、5.9.
5.2. 診断
brewの状態は、OSの更新やxcodeの更新、また無意識のうちにでも悪くなったりすることがあります。このコマンドで自身の診断が行えます。
$ brew doctor
インストール直後の場合は、以下のような表示になります。
$ brew doctor
Your system is ready to brew.
このままMacを使用し続けると、様々な問題が発生したりすることがあり、このコマンドで確認することが可能です。
5.3. パッケージの検索
パッケージの検索を行うことが可能です。
知りたいパッケージ名、サービス名、ライブラリ名を検索キーワードにして関連するfomula名を検索することが可能です。
$ brew search <free keyword>
では、実際に検索してみましょう。
ここでは、フォワードプロキシサービスであるsquidを検索します。
$ brew search squid
==> Formulae
squid
==> Casks
squidman
すると、squidの文字列からヒットしたfomulaがリストアップされました。
次に、ライブラリパッケージであるlibxml2で検索してみましょう。
$ brew search libxml2
==> Formulae
libxml2
ヒットしましたね。
パッケージ名をズバリ検索キーワードにしなくても、一部の文字列だけでも検索することができます。
$ brew search xml
==> Formulae
blahtexml gxml libnxml libxml2 tinyxml2 xml2 xmlsectool xmltoman
bzr-xmloutput html-xml-utils libwbxml libxmlsec1 xml-coreutils xmlcatmgr xmlsh
castxml latexml libxml++ pugixml xml-security-c xmlformat xmlstarlet
dbxml libmxml libxml++3 tinyxml xml-tooling-c xmlrpc-c xmlto
==> Casks
oxygen-xml-editor qxmledit
これらのfomula名を用いて、インストールを行っていきます。
5.4. パッケージのインストール
パッケージのインストールは以下のコマンドを実行します。
$ brew install <fomula_name>
では、実際に上記で登場したsquidをインストールしてみましょう。
$ brew install squid
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
go@1.12
==> Updated Formulae
exim git-quick-stats ipmitool qt skopeo spice-gtk
==> Installing dependencies for squid: openssl
==> Installing squid dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2s.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/c4/c4a762d719c2be74ac686f1aafabb32f3c5d5ff3a98935c4925a1ddb9c750ee1?__gda__=exp=15
######################################################################## 100.0%
==> Pouring openssl-1.0.2s.mojave.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
If you need to have openssl first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
==> Summary
🍺 /usr/local/Cellar/openssl/1.0.2s: 1,795 files, 12.0MB
==> Installing squid
==> Downloading https://homebrew.bintray.com/bottles/squid-4.8.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/ac/ac56304ff9094551025952da4883eb7ea48ec4be7eb6cd6baa1033ad5b464587?__gda__=exp=15
######################################################################## 100.0%
==> Pouring squid-4.8.mojave.bottle.tar.gz
==> Caveats
To have launchd start squid now and restart at login:
brew services start squid
Or, if you don't want/need a background service you can just run:
squid
==> Summary
🍺 /usr/local/Cellar/squid/4.8: 2,111 files, 9.6MB
==> Caveats
==> openssl
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
If you need to have openssl first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
==> squid
To have launchd start squid now and restart at login:
brew services start squid
Or, if you don't want/need a background service you can just run:
squid
インストールされました。
標準出力された各部分を説明していきます。
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
go@1.12
==> Updated Formulae
exim git-quick-stats ipmitool qt skopeo spice-gtk
brewでは、パッケージ操作のコマンドの場合、実行前に brew update が自動的に実行されます。この部分はその実行結果に当たります。
==> Installing dependencies for squid: openssl
==> Installing squid dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2s.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/c4/c4a762d719c2be74ac686f1aafabb32f3c5d5ff3a98935c4925a1ddb9c750ee1?__gda__=exp=15
######################################################################## 100.0%
==> Pouring openssl-1.0.2s.mojave.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
If you need to have openssl first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
==> Summary
🍺 /usr/local/Cellar/openssl/1.0.2s: 1,795 files, 12.0MB
squidに対して依存関係にある(squidパッケージをインストールするのに必要な)パッケージのインストールをしています。
ここでは、opensslのインストールが実行されています。
opensslはSSL暗号化のパッケージであり、インストールが成功したのちに、簡単な使用方法などが書かれています。
==> Installing squid
==> Downloading https://homebrew.bintray.com/bottles/squid-4.8.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/ac/ac56304ff9094551025952da4883eb7ea48ec4be7eb6cd6baa1033ad5b464587?__gda__=exp=15
######################################################################## 100.0%
==> Pouring squid-4.8.mojave.bottle.tar.gz
==> Caveats
To have launchd start squid now and restart at login:
brew services start squid
Or, if you don't want/need a background service you can just run:
squid
==> Summary
🍺 /usr/local/Cellar/squid/4.8: 2,111 files, 9.6MB
==> Caveats
==> openssl
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
If you need to have openssl first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
==> squid
To have launchd start squid now and restart at login:
brew services start squid
Or, if you don't want/need a background service you can just run:
squid
そしてsquidのインストールです。
インストール後、squidの簡単な説明の後、必要なopensslの使い方が再度記載されています。
実際にsquidが使えるか、whichコマンドを用いて確認してみましょう。
$ which squid
すると、出力されません。
実は、squidはデフォルトではPATHが通っていない場所、"/usr/local/sbin"に存在します。
では、代わりにnkfをインストールして確認してみましょう。
$ brew install nkf
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae
ant dialog enchant mercurial mill signal-cli zint
==> Downloading https://homebrew.bintray.com/bottles/nkf-2.1.5.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring nkf-2.1.5.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/nkf/2.1.5: 7 files, 365KB
$ which nkf
/usr/local/bin/nkf
現れました。
インストールができていることを確認できました。
5.5. インストール済みパッケージの確認
インストール済みパッケージを確認します。
以下のコマンドを実行します。
$ brew list
実際に実行してみると、以下のように表示されます。
$ brew list
gettext libunistring nkf openssl@1.1 wget
libidn2 mas openssl squid
このように、インストールされているパッケージの一覧が表示されます。
ここで、fomula名を指定して実行した場合、インストールされたファイル一覧が表示されます。
$ brew list squid
/usr/local/Cellar/squid/4.8/.bottle/etc/ (9 files)
/usr/local/Cellar/squid/4.8/bin/purge
/usr/local/Cellar/squid/4.8/bin/squidclient
/usr/local/Cellar/squid/4.8/homebrew.mxcl.squid.plist
/usr/local/Cellar/squid/4.8/libexec/ (35 files)
/usr/local/Cellar/squid/4.8/sbin/squid
/usr/local/Cellar/squid/4.8/share/errors/ (1980 files)
/usr/local/Cellar/squid/4.8/share/icons/ (51 files)
/usr/local/Cellar/squid/4.8/share/man/ (26 files)
/usr/local/Cellar/squid/4.8/share/mib.txt
5.6. パッケージのアンインストール
パッケージをアンインストールするときは、対象fomula名を指定して以下のように実行します。
$ brew uninstall <fomula_name>
実際にwgetを削除してみましょう。
$ brew uninstall wget
Uninstalling /usr/local/Cellar/wget/1.20.3_1... (50 files, 4.0MB)
このようにアンインストールできました。
アンインストールするパッケージのfomula名は"brew list"であらかじめ確認しておきましょう。
5.7. アップデートがあるパッケージ一覧
各パッケージは常に開発が進まれているケースが多く、バージョンアップされるとHomebrewにも反映されます。
もちろんインストールしている各パッケージにも反映することが可能であり、それを適用するタイミングも自由に制御できるようになっています。
Homebrewでは、その全パッケージの更新(バージョン)状況をLocal側で管理しており、以下のコマンドでその情報自体を更新することが可能です。
$ brew update
Already up-to-date.
何もなければ上記のように表示されますが、もしその情報が更新された場合、以下のように表示されます。
$ brew update
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
base91 octant
==> Updated Formulae
ack firebase-cli libbitcoin-network ooniprobe shairport
activemq flow libbitcoin-node opa shairport-sync
afl-fuzz flowgrind libbitcoin-protocol opencolorio ship
aliyun-cli fluxctl libbitcoin-server opencv siege
amazon-ecs-cli flyway libdap opencv@3 sile
amtk folly libexosip openfortivpn sip
angular-cli fossil libfreefare openimageio sipsak
ansible fpp libgcrypt openrct2 siril
ansible@1.9 fq libheif opensc skaffold
ansible@2.0 freeradius-server libjwt openssh skopeo
apache-geode freetds libmowgli openvpn slrn
apache-spark frpc libmypaint operator-sdk smali
appscale-tools frps libphonenumber ophcrack sngrep
aravis frugal libpqxx orc-tools socat
asio gambit-scheme libpulsar osc sofia-sip
ask-cli gammu libre oscats softhsm
astrometry-net gdal librsvg osquery sonobuoy
atlantis gdcm libsecret paket source-highlight
autorest geoipupdate libsignal-protocol-c pango sourcekitten
avro-c gerbil-scheme libslax passenger sourcery
avro-cpp getxbook libtins pdns sphinx
avro-tools git-crypt libtrace pdnsrec spiped
aws-okta gkrellm libu2f-server pev sqlcipher
awscli glances libvirt pgroonga sqlmap
babel glib links php srt
badtouch glib-openssl lmod php@7.1 ssh-audit
bash globus-toolkit logrotate php@7.2 ssh-permit-a38
bat glooctl logtalk picard-tools ssldump
bcftools gloox lolcat pijul starship
bedtools gmic luvit pjproject step
benthos gnupg-pkcs11-scd lxc pkcs11-helper stress-ng
boost gnuradio lynx plantuml strongswan
boost-bcp go mackup platformio stunnel
boost-build gocryptfs makensis poco stuntman
boost-mpi godep makepkg podofo swagger-codegen
boost-python goreleaser mariadb ponyc swiftlint
boost-python3 gpac mariadb-connector-c postgresql sylpheed
breezy gradle mariadb-connector-odbc presto sync_gateway
bro grafana mariadb@10.0 profanity syncthing
btfs groonga mariadb@10.1 proj tarantool
buku gsl mariadb@10.2 protobuf tarsnap
cadaver gsoap mariadb@10.3 protobuf@3.6 taskell
caf gspell maven protobuf@3.7 tcl-tk
cfn-lint gst-plugins-good maxwell pspg tcpdump
cglm gtk+3 md5sha1sum psqlodbc tcpflow
cgrep gtmess memcached pulledpork tdlib
charm-tools gwyddion mesa pulumi tectonic
checkstyle hadolint mfterm pure-ftpd telegraf
cimg helmfile micronaut pwntools teleport
citus hive miller pwsafe terraform
clamav hledger minio-mc pyenv terragrunt
cmake htpdate miniserve pygobject3 tile38
collectd hub mit-scheme pypy tinc
collector-sidecar hugo mkl-dnn pypy3 tiny-fugue
conan hyperfine mktorrent pyqt tomcat-native
consul-template i2p mkvtoolnix pyside trafficserver
convox icecast molecule python@2 ttyd
cryptol ike-scan monero pyvim tunnel
csound imapfilter monetdb qca u-boot-tools
cubelib inlets mongoose qmmp unbound
cucumber-cpp intercal monit qpdf unrar
davix iperf3 monitoring-plugins qpid-proton unshield
dcos-cli ipython mono qscintilla2 uptimed
ddgr ircd-hybrid mpg123 qsoas uwsgi
deno ircii mupdf quickjs vala
dieharder irssi mysql rabbitmq-c valabind
diffoscope janet mysql@5.7 rdesktop varnish
django-completion jenkins nagios-plugins re2 verilator
dnsviz jfrog-cli-go nano readline vgmstream
docfx joplin ncmpcpp rename vim
docker jose nco repo vips
docker-completion jpeg-turbo ncrack riff visp
docker-machine juise neo4j rom-tools vtk
doctl juju neofetch root vulkan-headers
dovecot kore neon rtags wdc
dub krb5 net-snmp ruby webtorrent-cli
duplicity kubectx netlify-cli ruby@2.4 weechat
dylibbundler kubeseal nginx ruby@2.5 widelands
dynare ldapvi ngircd s-nail wine
emacs ldid nmap s2geometry wireguard-tools
embree ldns nmh s3-backer wtf
emscripten ledger node sagittarius-scheme wtfutil
erlang@20 lftp nopoll sane-backends xcodegen
eslint lgogdownloader nordugrid-arc sblim-sfcc youtube-dl
etcd libarchive nrpe sbt zbackup
ethereum libbitcoin nsq scamper zim
exploitdb libbitcoin-blockchain nss sccache znc
fauna-shell libbitcoin-client ntp scdoc zsxd
ffsend libbitcoin-consensus nushell scrypt
fibjs libbitcoin-database nzbget sdhash
findutils libbitcoin-explorer ocrmypdf sdl2
==> Deleted Formulae
cclive liblacewing mongodb@3.4 postgres-xc xar-mackyle
frag_find libopkele mongodb@3.6 thc-pptp-bruter
freetds@0.91 mongodb packetbeat tlsdate
ftimes mongodb@3.0 percona-server-mongodb tn5250
httest mongodb@3.2 pincaster voms
各パッケージの最新バージョン情報だけでなく、新しいパッケージの追加や、削除されたパッケージなども情報が更新されます。
5.8. パッケージのアップデート
5.7.ではHomebrewで管理されてる全てのパッケージのバージョン情報を更新する方法をご説明しましたが、こちらではインストールされているパッケージの更新を行います。
この更新は、5.7.の情報を基にパッケージ自体の更新を行うことになります。
$ brew upgrade
現時点では更新はかかりませんでしたが、実際に更新される場合、パッケージは新たにインストールするような表示が現れます。
実際には、古いバージョンも新しいバージョンもMacには残った状態になります。
5.9. 同一パッケージのバージョン整理
5.8でパッケージの更新が行われますが、実は更新前のバージョンが削除されたり上書きされるのではなく以下の操作が行われています。
- パッケージ更新確認
- 新しいバージョンのパッケージインストール
- リンクの切り替えで新しいバージョンに
ということは、更新する度に新しいバージョンが同じようにインストールされることになり、ディスク容量への圧迫は激しいものとなります。
そこで、このコマンドで古いバージョンを整理する必要があります。
コマンドは以下の通りです。
$ brew cleanup
実際に実行してみましょう。
$ brew cleanup
Pruned 0 symbolic links and 4 directories from /usr/local
まだ更新が実施されていないために、整理するバージョンがありませんでした。
これを定期的に実施することで、ディスク容量への圧迫を軽減することが可能です。
注)パッケージによっては、あるバージョンを更新したくない場合もあり、そのバージョンを削除したくない場合があリます。この場合は"brew cleanup"で意図せず削除されてしまう可能性があることにご留意ください。
6. 環境移行
例えばMacを新調するなど、今まで使用しているMacから別のMacに環境を移したいことがあります。
その場合に便利なBrewfileというものがあります。
6.1 Brewfileの生成
新しい環境に引っ越す前に、インストール済みのパッケージリストをBrewfileを生成して書き出します。
コマンドは次の通りです。
$ brew bundle dump
カレントディレクトリ内にBrewfileが生成されます。
実行すると、以下のように表示されます。
$ brew bundle dump
==> Tapping homebrew/bundle
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-bundle'...
remote: Enumerating objects: 90, done.
remote: Counting objects: 100% (90/90), done.
remote: Compressing objects: 100% (80/80), done.
remote: Total 90 (delta 6), reused 29 (delta 4), pack-reused 0
Unpacking objects: 100% (90/90), done.
Tapped 1 command (186 files, 252.0KB).
ファイルの中は以下のようになっています。
$ cat Brewfile
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/core"
brew "mas"
brew "nkf"
brew "squid"
mas "GarageBand", id: 682658836
mas "iMovie", id: 408981434
mas "Keynote", id: 409183694
mas "Numbers", id: 409203825
mas "Pages", id: 409201541
mas "Server", id: 883878097
mas "XMind", id: 1327661892
brew、cask、masが一括で保存されています。
6.2 Brewfileからパッケージをインストール
新しい環境にBrewfileをコピーし、同じディレクトリ内に移動して以下のコマンドを実行します。
$ brew bundle