Can't install pg gem on Windows Can't install pg gem on Windows windows windows

Can't install pg gem on Windows


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


PsAdding for linux users.

I solved this error installing libpq-dev.


I fought this for two days. I do my rails command line stuff from the excellent unixy like command window provided by msysgit. I created a postgresql-path.bat file that contained

@set PATH=%PATH%;C:\Progra~1\PostgreSQL\8.3\bin@set PATH=%PATH%;C:\Progra~1\PostgreSQL\8.3\include@set PATH=%PATH%;C:\Progra~1\PostgreSQL\8.3

At the top of the msys.bat file I added

CALL postgresql-path.bat

As soon as I got the space out of my PATH variable for the postgreSQL directories my problems installing 'pg' went away. Hope this saves somebody the problems I had.