動機
『 brew upgrade
したいけど、特定のformulaだけバージョンを固定したい!!』
・・・あると思います。
brew pin
brew pin
というコマンドを使うと brew upgrade
の対象外とすることができます。
$ brew pin --help
brew pin formulae:
Pin the specified formulae, preventing them from being upgraded when
issuing the brew upgrade formulae command. See also unpin.
pinを解除するには brew unpin
すればOKです。
$ brew unpin --help
brew unpin formulae:
Unpin formulae, allowing them to be upgraded by brew upgrade formulae.
See also pin.
実践例
Terraformの特定のバージョンにバグがあるため v0.11.3 に固定したい、ということがあったので brew pin
を実際に試してみました。
まず現状のバージョンを確認します。
$ terraform -v
Terraform v0.11.3
Your version of Terraform is out of date! The latest version
is 0.11.7. You can update by downloading from www.terraform.io/downloads.html
upgrade対象外にするべく brew pin
を実行します。
$ brew pin terraform
brew info
して pinned になったことを確認します。
ここでは [pinned at 0.11.7]
と出ていますが、upgrade対象外となるため v0.11.3 からupgradeされることはありません。
$ brew info terraform
terraform: stable 0.11.7 (bottled), HEAD [pinned at 0.11.7]
Tool to build, change, and version infrastructure
https://www.terraform.io/
Conflicts with:
tfenv (because tfenv symlinks terraform binaries)
/usr/local/Cellar/terraform/0.11.3 (7 files, 79.9MB) *
Poured from bottle on 2018-03-20 at 18:49:55
/usr/local/Cellar/terraform/0.11.4 (7 files, 80.2MB)
Poured from bottle on 2018-03-20 at 18:56:15
/usr/local/Cellar/terraform/0.11.5 (7 files, 80.2MB)
Poured from bottle on 2018-03-22 at 11:20:46
/usr/local/Cellar/terraform/0.11.7 (6 files, 80.2MB)
Poured from bottle on 2018-04-17 at 18:13:05
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/terraform.rb
==> Dependencies
Build: go ✘, gox ✘
==> Options
--HEAD
Install HEAD version
brew upgrade
してterraformがupgradeされるか確認してみます。
$ brew upgrade
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
amtk
==> Updated Formulae
packer ✔ ansiweather charm fakeroot fwup grpc nifi pulseaudio util-linux
sphinx-doc ✔ bareos-client cockroach file-roller gitlab-runner mutt npth tepl vala
xonsh ✔ binaryen conjure-up folly gnome-latex neomutt overmind tiger-vnc webpack
==> Upgrading 37 outdated packages, with result:
vim 8.0.1600 -> 8.1.0150, ...(中略)... , packer 1.2.1 -> 1.2.5
upgrade対象から確かに外れました!やったぜ!