Problem installing pg in kali linux

Issue #264 invalid
sasatefa2009 created an issue

this is the output of gem install pg

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/rvm/gems/ruby-2.4.1/gems/pg-0.21.0/ext
/usr/local/rvm/rubies/ruby-2.4.1/bin/ruby -r ./siteconf20170905-28514-1gewc8i.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
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=/usr/local/rvm/rubies/ruby-2.4.1/bin/$(RUBY_BASE_NAME)
    --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:

  /usr/local/rvm/gems/ruby-2.4.1/extensions/x86_64-linux/2.4.0/pg-0.21.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/rvm/gems/ruby-2.4.1/gems/pg-0.21.0 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.4.1/extensions/x86_64-linux/2.4.0/pg-0.21.0/gem_make.out

the mkmf.log is attached

Comments (7)

  1. Chris Bandy
    checking for libpq-fe.h... no
    Can't find the 'libpq-fe.h header
    

    You need the libpq development headers. Usually package libpq-dev on Debian flavors.

  2. sasatefa2009 reporter

    @Chris Bandy Well, i have already installed libpq-dev and checked again before writing this comment. sudo apt-get install --reinstall libpq-dev but still the same problem

  3. sasatefa2009 reporter

    also i found that when i run "sudo gem install pg" it comes with another error

    Building native extensions.  This could take a while...
    ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.
    
        current directory: /var/lib/gems/2.3.0/gems/pg-0.21.0/ext
    /usr/bin/ruby2.3 -r ./siteconf20170907-2143-11ddksv.rb extconf.rb
    checking for pg_config... no
    No pg_config... trying anyway. If building fails, please try again with
     --with-pg-config=/path/to/pg_config
    checking for libpq-fe.h... *** 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=/usr/bin/$(RUBY_BASE_NAME)2.3
        --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
    /usr/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
    You have to install development tools first.
        from /usr/lib/ruby/2.3.0/mkmf.rb:587:in `try_cpp'
        from /usr/lib/ruby/2.3.0/mkmf.rb:1144:in `block in find_header'
        from /usr/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
        from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
        from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
        from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
        from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
        from /usr/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
        from /usr/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
        from /usr/lib/ruby/2.3.0/mkmf.rb:1143:in `find_header'
        from extconf.rb:54:in `<main>'
    
    To see why this extension failed to compile, please check the mkmf.log which can be found here:
    
      /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/pg-0.21.0/mkmf.log
    
    extconf failed, exit code 1
    
    Gem files will remain installed in /var/lib/gems/2.3.0/gems/pg-0.21.0 for inspection.
    Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/pg-0.21.0/gem_make.out
    
  4. Celso Annes

    I had the same problem on Debian 8, I solved it when I installed libpq-dev.

    sudo apt-get install libpq-dev
    
  5. Michael Granger repo owner

    The error output is already fairly clear, and the suggestions later in the issue comments are correct.

  6. Log in to comment