2

I am working on starting a new project and I am getting an error I can't resolve after following the error's suggestions. Anybody out there know of any reason why Ruby 2.1.2 should not play well with Rails 4.2.6 when installing postgresql database? I am getting this type of error:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby 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.

I checked the logs and it might as well have been in hieroglyphics:

"gcc -E -I/Users/danale/.rvm/rubies/ruby-2.3.3/include/ruby-2.3.0/x86_64-darwin16 -I/Users/danale/.rvm/rubies/ruby-2.3.3/include/ruby-2.3.0/ruby/backward -I/Users/danale/.rvm/rubies/ruby-2.3.3/include/ruby-2.3.0 -I.  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe  conftest.c -o conftest.i"
conftest.c:3:10: fatal error: 'libpq-fe.h' file not found
#include <libpq-fe.h>
         ^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
/* end */

I since changed to Ruby version 2.1.2, hoping it was a compatibility issue, but it did not resolve the error. When I try to follow the suggestions of error:

Gem files will remain installed in /Users/danale/.rvm/gems/ruby-2.1.2/gems/pg-0.19.0 for inspection.
Results logged to /Users/danale/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-16/2.1.0/pg-0.19.0/gem_make.out
danales-MacBook-Pro:Projects danale$ bundle exec spring binstub --all
Could not locate Gemfile or .bundle/ directory
danales-MacBook-Pro:Projects danale$ bundle install
Could not locate Gemfile

I get what you see above.

Daniel
  • 14,004
  • 16
  • 96
  • 156

3 Answers3

3

Daniel nailed this in the comments and I don't need credit for it, but if you're a Mac user you need to use:

brew install postgresql
moondaisy
  • 4,303
  • 6
  • 41
  • 70
1

This error means you don't have the headers to compile the native extensions in your machine. You may install them by doing:

 brew install postgresql

ot then

gem install pg -- --with-pg-config='PG_CONFIG_PATH'

and then try to run bundle install again.

You may read more about this here.

Ed de Almeida
  • 3,675
  • 4
  • 25
  • 57
0

Try this: Go to System Settings => Open Software & Updates, you need to have both trusty-security & trusty-updates are enabled under the Updates tab, then reload your sources & see if you get the current versions. After that open your terminal and run sudo apt-get update.

spirito_libero
  • 1,206
  • 2
  • 13
  • 21