0

I'm a newbie in ruby and rails development. I know that rails uses sqlite3 as default, so I want to try using postgres as defalut. I've downloaded postgres, jruby, ruby 2.5.1, rails 5.2.1. I've intalled ruby devkit with ruby dk.rb init/install. I'm stumbled into the wall when I try to install pg gem, I get the following output:

Building native extensions.  This could take a while...
C:/jruby-9.1.17.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:58: warning: Tempfile#unlink or delete called on open file; ignoring
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.
    current directory: C:/jruby-9.1.17.0/lib/ruby/gems/shared/gems/pg-1.1.3/ext
C:/jruby-9.1.17.0/bin/jruby.exe -r ./siteconf20180918-6200-16mdyzt.rb extconf.rb
checking for pg_config... yes
Using config values from C:\postgres\bin/pg_config.exe
RuntimeError: The compiler failed to generate an executable file.
You have to install development tools first.

     try_do at C:/jruby-9.1.17.0/lib/ruby/stdlib/mkmf.rb:456
  try_link0 at C:/jruby-9.1.17.0/lib/ruby/stdlib/mkmf.rb:541
   try_link at C:/jruby-9.1.17.0/lib/ruby/stdlib/mkmf.rb:556
     <main> at extconf.rb:40
*** 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:/jruby-9.1.17.0/bin/jruby
        --with-pg
        --without-pg
        --enable-windows-cross
        --disable-windows-cross
        --with-pg-config
        --without-pg-config
        --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
To see why this extension failed to compile, please check the mkmf.log which can be found here:
  C:/jruby-9.1.17.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/pg-1.1.3/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/jruby-9.1.17.0/lib/ruby/gems/shared/gems/pg-1.1.3 for inspection.
Results logged to C:/jruby-9.1.17.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/pg-1.1.3/gem_make.out

mkmf.log contains:

find_executable: checking for pg_config... -------------------- yes

--------------------

" -o conftest.exe -I/include/universal-java1.8 -IC:/jruby-9.1.17.0/lib/ruby/include/ruby/backward -IC:/jruby-9.1.17.0/lib/ruby/include -I. -IC:/postgres/include     -fno-omit-frame-pointer -fno-strict-aliasing  -fexceptions  conftest.c  -L. -LC:/jruby-9.1.17.0/lib -LC:/postgres/lib  -LC:/jruby-9.1.17.0/lib/native/x86_64-Windows   -m64 -march=native -mtune=native      "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <ruby.h>
4: int main(int argc, char **argv)
5: {
6:   return 0;
7: }
/* end */
kimor
  • 3
  • 3

1 Answers1

0

Have you installed postgres package in your system You can install in linux using command

sudo apt-get install postgresql postgresql-contrib

if you are using debian system

The error clearly states that that you need to install development tools so you may have likely missed installing some dependencies

You can install through command line utitlities using the commands

     @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://s3.amazonaws.com/pgcentral/install.ps1'))"
     cd bigsql
     pgc install pg10
     pgc start pg10

Please follow this link to configure postgress in windows

To install postgres client, please refer to this stackoverflow link and also try to install pg gem by specifying the path of pgconfig file you can refer to this link for example

Sumanth Madishetty
  • 3,425
  • 2
  • 12
  • 24