Skip to content

Instantly share code, notes, and snippets.

@leonmezu1
Forked from djberg96/gist:2966965
Created January 8, 2021 19:56
Show Gist options
  • Save leonmezu1/a9bd130b3619055c327d8909e4829fec to your computer and use it in GitHub Desktop.
Save leonmezu1/a9bd130b3619055c327d8909e4829fec to your computer and use it in GitHub Desktop.
Trouble installing pg gem on Windows
# I've got a have_library call failing when I tried to install the pg gem
c:\Users\djberge\Downloads\Ruby>gem install pg -- --with-pg-dir="c:\Program Files (x86)\PostgreSQL\9.1"
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
c:/usr/bin/ruby.exe extconf.rb --with-pg-dir=c:\Program Files (x86)\PostgreSQL\9.1
checking for pg_config... yes
Using config values from c:\Program Files (x86)\PostgreSQL\9.1\bin/pg_config.exe
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in pq.lib... no
checking for PQconnectdb() in libpq.lib... no
checking for PQconnectdb() in ms/libpq.lib... no
Can't find the PostgreSQL client library (libpq)
*** 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.
# But works fine if I build "manually"
c:\Users\djberge\Downloads\Ruby\pg-0.13.2\ext>ruby extconf.rb --with-pg-dir="c:\Program Files (x86)\PostgreSQL\9.1"
checking for pg_config... yes
Using config values from c:\Program Files (x86)\PostgreSQL\9.1\bin/pg_config.exe
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in pq.lib... no
checking for PQconnectdb() in libpq.lib... yes # => YUP
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 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 rb_encdb_alias()... yes
checking for rb_enc_alias()... yes
checking for struct pgNotify.extra in libpq-fe.h... yes
checking for unistd.h... no
checking for ruby/st.h... yes
creating extconf.h
creating Makefile
# The portion of the extconf.rb file in question is:
have_library( 'pq', 'PQconnectdb', ['libpq-fe.h'] ) ||
have_library( 'libpq', 'PQconnectdb', ['libpq-fe.h'] ) ||
have_library( 'ms/libpq', 'PQconnectdb', ['libpq-fe.h'] )
# UPDATE
Using the short path worked:
gem install pg -- --with-pg-dir="c:/PROGRA~2/POSTGR~1/9.1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment