Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't install pg gem on Windows

I've got 2 Ruby versions: 1.8.7 and 1.9.2 and PostgreSQL 8.3. I cant install pg gem on any of them. Getting this error:

C:/Development/Ruby187/bin/ruby.exe extconf.rb checking for pg_config... yes not recorded 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  --without-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=C:/Development/Ruby187/bin/ruby  --with-pg  --without-pg  --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 

I know it's a common problem, but I haven't found any working solution yet... Oh, I have added C:\Program Files (x86)\PostgreSQL\8.3\bin to my PATH.

like image 426
sNiCKY Avatar asked Dec 02 '10 13:12

sNiCKY


2 Answers

The message you're getting is a clear indication that you lack something for the correct installation of that gem:

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.

There is no Windows native version of latest release of pg (0.10.0) released yesterday, but if you install 0.9.0 it should install binaries without issues.

Anyhow, if you want to install the gem, you need a build environment installed. If you're using RubyInstaller, then you need the DevKit

Installation of the gem will only require you provide additional options to gem installation (like --with-pg-dir)

subst X: "C:\Program Files (x86)\PostgreSQL\8.3" gem install pg -- --with-pg-dir=X: subst X: /D 
like image 140
Luis Lavena Avatar answered Oct 11 '22 14:10

Luis Lavena


PsAdding for linux users.

I solved this error installing libpq-dev.

like image 37
FabricioFCarv Avatar answered Oct 11 '22 13:10

FabricioFCarv