0

When I include

group :production do
  gem 'pg'
end

in my gemfile and run 'bundle install' I get an error saying:

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

            /Users/sharatakasapu/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb 
    checking for pg_config... yes
    Using config values from /usr/bin/pg_config
    checking for libpq-fe.h... yes
    checking for libpq/libpq-fs.h... yes
    checking for pg_config_manual.h... yes
    checking for PQconnectdb() in -lpq... yes
    checking for PQconnectionUsedPassword()... yes
    checking for PQisthreadsafe()... yes
    checking for PQprepare()... yes
    checking for PQexecParams()... yes
    checking for PQescapeString()... yes
    checking for PQescapeStringConn()... yes
    checking for PQescapeLiteral()... yes
    checking for PQescapeIdentifier()... yes
    checking for PQgetCancel()... yes
    checking for lo_create()... yes
    checking for pg_encoding_to_char()... yes
    checking for pg_char_to_encoding()... yes
    checking for PQsetClientEncoding()... yes
    checking for PQlibVersion()... yes
    checking for PQping()... yes
    checking for PQsetSingleRowMode()... no
    checking for rb_encdb_alias()... yes
    checking for rb_enc_alias()... yes
    checking for rb_thread_call_without_gvl()... yes
    checking for rb_thread_call_with_gvl()... yes
    checking for rb_thread_fd_select()... yes
    checking for rb_w32_wrap_io_handle()... no
    checking for PGRES_COPY_BOTH in libpq-fe.h... no
    checking for PGRES_SINGLE_TUPLE in libpq-fe.h... no
    checking for struct pgNotify.extra in libpq-fe.h... yes
    checking for unistd.h... yes
    checking for ruby/st.h... yes
    creating extconf.h
    creating Makefile

    make
    gcc-4.2 -I. -I/Users/sharatakasapu/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/x86_64-darwin12.2.1 -I/Users/sharatakasapu/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/ruby/backward -I/Users/sharatakasapu/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1 -I. -DRUBY_EXTCONF_H=\"extconf.h\" -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/include -fno-common -O3 -I/opt/sm/pkg/active/include -fno-common -pipe  -o gvl_wrappers.o -c gvl_wrappers.c
    gcc-4.2 -I. -I/Users/sharatakasapu/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/x86_64-darwin12.2.1 -I/Users/sharatakasapu/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/ruby/backward -I/Users/sharatakasapu/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1 -I. -DRUBY_EXTCONF_H=\"extconf.h\" -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/include -fno-common -O3 -I/opt/sm/pkg/active/include -fno-common -pipe  -o pg.o -c pg.c
    pg.c: In function ‘Init_pg_ext’:
    pg.c:384: error: ‘PQPING_OK’ undeclared (first use in this function)
    pg.c:384: error: (Each undeclared identifier is reported only once
    pg.c:384: error: for each function it appears in.)
    pg.c:386: error: ‘PQPING_REJECT’ undeclared (first use in this function)
    pg.c:388: error: ‘PQPING_NO_RESPONSE’ undeclared (first use in this function)
    pg.c:390: error: ‘PQPING_NO_ATTEMPT’ undeclared (first use in this function)
    make: *** [pg.o] Error 1


    Gem files will remain installed in /Users/sharatakasapu/.bundler/tmp/36975/gems/pg-0.15.1 for inspection.
    Results logged to /Users/sharatakasapu/.bundler/tmp/36975/gems/pg-0.15.1/ext/gem_make.out

    An error occurred while installing pg (0.15.1), and Bundler cannot continue.
    Make sure that `gem install pg -v '0.15.1'` succeeds before bundling.

When I do:

Sharats-MacBook-Pro:sentiment sharatakasapu$ which pg_config
    /usr/bin/pg_config
    Sharats-MacBook-Pro:sentiment sharatakasapu$ gem install pg -- --with-pg-config= '/usr/bin/pg_config'
    Building native extensions.  This could take a while...
    ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

            /Users/sharatakasapu/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb --with-pg-config= /usr/bin/pg_config
    Using config values from 
    sh: : command not found
    sh: : command not found
    checking for libpq-fe.h... yes
    checking for libpq/libpq-fs.h... yes
    checking for pg_config_manual.h... yes
    checking for PQconnectdb() in -lpq... yes
    checking for PQconnectionUsedPassword()... yes
    checking for PQisthreadsafe()... yes
    checking for PQprepare()... yes
    checking for PQexecParams()... yes
    checking for PQescapeString()... yes
    checking for PQescapeStringConn()... yes
    checking for PQescapeLiteral()... yes
    checking for PQescapeIdentifier()... yes
    checking for PQgetCancel()... yes
    checking for lo_create()... yes
    checking for pg_encoding_to_char()... yes
    checking for pg_char_to_encoding()... yes
    checking for PQsetClientEncoding()... yes
    checking for PQlibVersion()... yes
    checking for PQping()... yes
    checking for PQsetSingleRowMode()... no
    checking for rb_encdb_alias()... yes
    checking for rb_enc_alias()... yes
    checking for rb_thread_call_without_gvl()... yes
    checking for rb_thread_call_with_gvl()... yes
    checking for rb_thread_fd_select()... yes
    checking for rb_w32_wrap_io_handle()... no
    checking for PGRES_COPY_BOTH in libpq-fe.h... no
    checking for PGRES_SINGLE_TUPLE in libpq-fe.h... no
    checking for struct pgNotify.extra in libpq-fe.h... yes
    checking for unistd.h... yes
    checking for ruby/st.h... yes
    creating extconf.h
    creating Makefile

    make
    gcc-4.2 -I. -I/Users/sharatakasapu/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/x86_64-darwin12.2.1 -I/Users/sharatakasapu/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/ruby/backward -I/Users/sharatakasapu/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1 -I. -DRUBY_EXTCONF_H=\"extconf.h\" -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I -fno-common -O3 -I/opt/sm/pkg/active/include -fno-common -pipe  -o gvl_wrappers.o -c gvl_wrappers.c
    gcc-4.2 -I. -I/Users/sharatakasapu/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/x86_64-darwin12.2.1 -I/Users/sharatakasapu/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/ruby/backward -I/Users/sharatakasapu/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1 -I. -DRUBY_EXTCONF_H=\"extconf.h\" -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I -fno-common -O3 -I/opt/sm/pkg/active/include -fno-common -pipe  -o pg.o -c pg.c
    pg.c: In function ‘Init_pg_ext’:
    pg.c:384: error: ‘PQPING_OK’ undeclared (first use in this function)
    pg.c:384: error: (Each undeclared identifier is reported only once
    pg.c:384: error: for each function it appears in.)
    pg.c:386: error: ‘PQPING_REJECT’ undeclared (first use in this function)
    pg.c:388: error: ‘PQPING_NO_RESPONSE’ undeclared (first use in this function)
    pg.c:390: error: ‘PQPING_NO_ATTEMPT’ undeclared (first use in this function)
    make: *** [pg.o] Error 1

I've been going through answers on SO but am having little success to fix this error. Any advice?

sharataka
  • 5,014
  • 20
  • 65
  • 125
  • Have you checked out this answer?http://stackoverflow.com/questions/9668753/rails-3-cant-install-pg-gem – Eric Fode Apr 28 '13 at 22:11
  • http://stackoverflow.com/questions/12273815/cant-install-pg-gem-on-mountain-lion/12273968#12273968 I have answered here :) – uday Apr 28 '13 at 22:16
  • Or this one ? http://stackoverflow.com/questions/11711394/pg-gem-0-14-0-on-mountain-lion-fails – Ian Kenney Apr 28 '13 at 22:17
  • My question is why do I have to install postgres on my local machine if I'm only using it in the production environment? – sharataka Apr 28 '13 at 22:21
  • 1
    You can do that if you run `bundle install --without production` – rossta Apr 28 '13 at 22:25
  • But if I bundle everything together on my local machine, I need to have pg installed even though on my local/development environment I specified using sqlite in the gemfile? – sharataka Apr 28 '13 at 22:31

0 Answers0