Skip to content

Instantly share code, notes, and snippets.

@kachick
Created July 30, 2018 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kachick/7c3584a538c6ac582561dcd610600cc1 to your computer and use it in GitHub Desktop.
Save kachick/7c3584a538c6ac582561dcd610600cc1 to your computer and use it in GitHub Desktop.
pg gem のインストール時にpg_config ~ libpq-feでコケたら

TL;DR

gem install pg -v '0.21.0' --source 'https://rubygems.org/' -- --with-pg-config=/usr/local/Cellar/postgresql@9.4/9.4.18/bin/pg_config

こんなエラーが出たときに上記で解消した。

gem install pg -v '0.21.0' --source 'https://rubygems.org/'
Building native extensions. This could take a while...
ERROR:  Error installing pg:
	ERROR: Failed to build gem native extension.

    current directory: /Users/kachick/.gem/ruby/2.5.0/gems/pg-0.21.0/ext
/Users/kachick/.rubies/ruby-2.5.0/bin/ruby -r ./siteconf20180730-86210-1omj48k.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/Users/kachick/.rubies/ruby-2.5.0/bin/$(RUBY_BASE_NAME)
	--with-pg
	--without-pg
	--enable-windows-cross
	--disable-windows-cross
	--with-pg-config
	--without-pg-config
	--with-pg_config
	--without-pg_config
	--with-pg-dir
	--without-pg-dir
	--with-pg-include
	--without-pg-include=${pg-dir}/include
	--with-pg-lib
	--without-pg-lib=${pg-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/kachick/.gem/ruby/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/pg-0.21.0/mkmf.log

extconf failed, exit code 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment