0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

homebrewでインストールして現在有効なパッケージのインストール場所を取得する

0
Posted at

現在インストールして利用しているパッケージのインストール先を取得したい。
雑実装でいかのように確認した

# !/bin/sh

function brew_installed_path() {
  FORMULA=$1
  CELLAR_PATH=$(brew --cellar $FORMULA)
  INSTALL_VERSION=$(brew info --json=v1 $FORMULA | jq -r "map(.linked_keg)[0]")
  echo $CELLAR_PATH/$INSTALL_VERSION
}

利用例

$ brew_installed_path git
/usr/local/Cellar/git/2.16.2

解説

brew --cellar $FORMULAでインストール先はわかるが、homebrewは複数のバージョンがインストールされている。現在linkされているバージョンがわからなければならない。
brew info --json=v1 $FORMULAを使うとformulaに関連する情報が得られる。linked_kegにlinkしているバージョンがはいっていたので、それを利用した。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?