Cannot install ruby-postgres on Windows

My system is Windows Server 2008 SP2

Ruby and gem versions:

C:\Windows\system32>ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mingw32]

C:\Windows\system32>gem -v
1.3.5

When I try to install the ruby-postgres gem, here is what it says:

C:\Windows\system32>gem install ruby-postgres
Building native extensions. This could take a while…
ERROR: Error installing ruby-postgres:
ERROR: Failed to build gem native extension.

C:/Ruby19/bin/ruby.exe extconf.rb
checking for main() in -lpq… *** 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:/Ruby19/bin/ruby
–with-pgsql-dir
–without-pgsql-dir
–with-pgsql-include
–without-pgsql-include=${pgsql-dir}/include
–with-pgsql-lib
–without-pgsql-lib=${pgsql-dir}/lib
–with-pqlib
–without-pqlib
C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:364:in try_do': The complier failed to generat e an executable file. (RuntimeError) You have to install development tools first. from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:417:intry_link0’
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:421:in try_link' from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:529:intry_func’
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:725:in block in have_library' from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:670:inblock in
checking_for’
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:276:in block (2 levels) in postpo ne' from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:250:inopen’
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:276:in block in postpone' from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:250:inopen’
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:272:in postpone' from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:669:inchecking_for’
from C:/Ruby19/lib/ruby/1.9.1/mkmf.rb:720:in have_library' from extconf.rb:17:inhave_build_env’
from extconf.rb:26:in `’

Gem files will remain installed in
C:/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-postg
res-0.7.1.2006.04.06 for inspection.
Results logged to
C:/Ruby19/lib/ruby/gems/1.9.1/gems/ruby-postgres-0.7.1.2006.04
.06/gem_make.out

Any help very welcome.
Sébastien

ruby-postgres is deprecated. Use “pg” instead.

Sharagoz – wrote:

You have to install development tools firs

Hello again.
It is trying to install from source instead of binary, which requires a
compiler.
Try setting the platform to mswin32 and it will hopefully install the
binary version.

gem install ruby-postgres --platform=mswin32

WORKS!

See below
Thanks!

==========================
Microsoft Windows [Version 6.0.6002]
Copyright © 2006 Microsoft Corporation. All rights reserved.

C:\Windows\system32>gem install ruby-postgres --platform=mswin32
Successfully installed ruby-postgres-0.7.1.2006.04.06-x86-mswin32
1 gem installed
Installing ri documentation for
ruby-postgres-0.7.1.2006.04.06-x86-mswin32…
Updating class cache with 1075 classes…
Installing RDoc documentation for
ruby-postgres-0.7.1.2006.04.06-x86-mswin32…

C:\Windows\system32>

You have to install development tools firs

Hello again.
It is trying to install from source instead of binary, which requires a
compiler.
Try setting the platform to mswin32 and it will hopefully install the
binary version.

gem install ruby-postgres --platform=mswin32

Try setting the platform to mswin32 and it will hopefully install the
binary version.

gem install ruby-postgres --platform=mswin32

Looks like this only installs binaries for 1.8.6 (same with the pg gem).
If you want to use ruby mingw 1.9.1 with them (which is the OP’s
version), you’ll have to download the headers and compile from source.

Roger P. wrote:

Try setting the platform to mswin32 and it will hopefully install the
binary version.

gem install ruby-postgres --platform=mswin32

Looks like this only installs binaries for 1.8.6 (same with the pg gem).
If you want to use ruby mingw 1.9.1 with them (which is the OP’s
version), you’ll have to download the headers and compile from source.

Thanks for the comment Roger.

Fernando P. wrote:

ruby-postgres is deprecated. Use “pg” instead.

Hello Fernando,

It also works with your suggestion, thank you.

But then, if both the deprecated ruby-postgres is installed along with
pg (see the gem list below), is there any problem ? Will rails use by
default pg instead of ruby-postgres ?

==========
C:\Windows\system32>gem install pg --platform=mswin32
Building native extensions. This could take a while…
Successfully installed pg-0.8.0-x86-mswin32-60
1 gem installed
Installing ri documentation for pg-0.8.0-x86-mswin32-60…
Updating class cache with 1081 classes…
Installing RDoc documentation for pg-0.8.0-x86-mswin32-60…

C:\Windows\system32>gem list

*** LOCAL GEMS ***

actionmailer (2.3.5)
actionpack (2.3.5)
activerecord (2.3.5)
activeresource (2.3.5)
activesupport (2.3.5)
daemons (1.0.10)
dependencies (0.0.8)
gem_plugin (0.2.3)
pg (0.8.0)
rack (1.0.1)
rails (2.3.5)
rake (0.8.7)
ruby-postgres (0.7.1.2006.04.06)
thor (0.13.3)
win32console (1.2.0)

C:\Windows\system32>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs