macOS で 'pg' を含む Gemfile を bundle install する方法

mallowlabs.hatenablog.com

という記事を6年前に書いたが、久しぶりにやったら動かなかったのでメモ。

環境

  • macOS 10.14.4 (Mojave)
  • Postgres.app 2.2.2
  • Ruby 2.6.2
  • Bundler 2.0.1

手順

  1. Postgres.app をインストールする 素直に /Applications/ 以下にコピーする

  2. Gemfile があるディレクトリで以下のコマンドを実行

$ bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
$ bundle

前の記事と比較として bundle config に渡す pg_config のパスが変更になっている。

まとめ

Mac OS XmacOS になっていたり Ruby が v2 になっていたり、Bundler が v2 になっていたり、時の流れを感じる。