Ask A Question

Notifications

You’re not receiving notifications from this thread.

Problem installing pg-1.1.4 as part of Rails 6 install

Dean Richardson asked in Gems / Libraries

I'm following the instructions in the post on installing a rails development environment for MacOS Catalina. I'm able to follow the steps up to checking the rails version:

$ rails -v
Could not find pg-1.1.4 in any of the sources
Run bundle install to install missing gems.

When I attempt bundle install, the process terminates do to a failed install of the pg gem:

Installing pg 1.1.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/deanrichardson/.rvm/gems/ruby-2.6.5/gems/pg-1.1.4/ext
/Users/deanrichardson/.rvm/rubies/ruby-2.6.5/bin/ruby -I
/Users/deanrichardson/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0 -r
./siteconf20191225-4044-8bk372.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/deanrichardson/.rvm/rubies/ruby-2.6.5/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/deanrichardson/.rvm/gems/ruby-2.6.5/extensions/x86_64-darwin-19/2.6.0/pg-1.1.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
/Users/deanrichardson/.rvm/gems/ruby-2.6.5/gems/pg-1.1.4 for inspection.
Results logged to
/Users/deanrichardson/.rvm/gems/ruby-2.6.5/extensions/x86_64-darwin-19/2.6.0/pg-1.1.4/gem_make.out

An error occurred while installing pg (1.1.4), and Bundler cannot
continue.
Make sure that gem install pg -v '1.1.4' --source 'https://rubygems.org/'
succeeds before bundling.

Any suggestions for diagnosing what might have gone wrong? I've looked at the log file in question and it suggests missing headers.

I've tried using the fix given later in your post:

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

and this also generated an error message.

Thanks,

--Dean Richardson

Reply

I was able to resolve this by upgrading my bundler version than reinstalling the gem.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.