Skip to content

Instantly share code, notes, and snippets.

@caike
Last active December 20, 2015 14:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caike/6148957 to your computer and use it in GitHub Desktop.
Save caike/6148957 to your computer and use it in GitHub Desktop.
Installing pg gem on Ruby 2.0

Installing pg gem on Ruby 2.0

When installing the pg gem on Ruby 2.0 I ran into the following issues:

pg.c: In function ‘pg_s_library_version’:
pg.c:272: warning: implicit declaration of function ‘PQlibVersion’
pg.c: In function ‘Init_pg_ext’:
pg.c:375: error: ‘PQPING_OK’ undeclared (first use in this function)
pg.c:375: error: (Each undeclared identifier is reported only once
pg.c:375: error: for each function it appears in.)
pg.c:377: error: ‘PQPING_REJECT’ undeclared (first use in this function)
pg.c:379: error: ‘PQPING_NO_RESPONSE’ undeclared (first use in this function)
pg.c:381: error: ‘PQPING_NO_ATTEMPT’ undeclared (first use in this function)
make: *** [pg.o] Error 1

To solve this:

  1. run locate pg_config
  2. Find the binary (mine is /usr/local/bin/pg_config)
  3. gem install pg -v '0.16.0' -- with-pg-config=/usr/local/bin/pg_config

UPDATE #1: If this still fails with pg version 0.16.0, then downgrade to version 0.15.1 and it should work. Add the following to your Gemfile: gem 'pg', '~> 0.15.1'

UPDATE #2: When I really came to need version 0.16.0, I simply re-installed postgresql via homebrew (updating homebrew was probably what broke everything in the first place)

@caike
Copy link
Author

caike commented Aug 19, 2013

Hey @bruceyue, try downgrading it to pg version 0.15.1. Still having some issues with the latest 0.16.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment