LoginSignup
244
199

More than 1 year has passed since last update.

macOSでgem install pgしてNo pg_configとなる対処法

Last updated at Posted at 2013-10-05

Homebrewが入っていれば

$ brew install libpq

libpq をインストールする。 brew install postgresql すると書いてある記事もあるが(この記事にもそう書いていた)、これだとサーバーも入ってしまう。サーバーもMacにインストールしたいなら postgresql でOKだが、サーバーはDocker等で動かすのでMacにはクライアントのみで問題ないということなら libpq とするほうが良い。

インストールしていてpg_configがあるはずと思う場合

以下コマンドでどこにインストールされているかが調べられる:

$ brew info libpq
libpq: stable 14.5 (bottled) [keg-only]
Postgres C API library
https://www.postgresql.org/docs/14/libpq.html
/opt/homebrew/Cellar/libpq/14.5 (2,340 files, 28.3MB)
  Poured from bottle on 2022-08-23 at 14:20:09
(以下略)

/opt/homebrew/Cellar/libpq/14.5 にインストールされていることがわかり、以下のようにすればインストール可能。

$ gem install pg --with-pg-config=/opt/homebrew/Cellar/libpq/14.5/bin/pg_config

また、bundle installの中でこのエラーが出るようなら、以下のようにしてbundle installの過程でインストールされるgemに引数を渡せる。

$ bundle config build.pg --with-pg-config=/opt/homebrew/Cellar/libpq/14.5/bin/pg_config
$ bundle install
244
199
2

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
244
199