Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An error occurred while installing pg (0.18.4), and Bundler cannot continue

I encounter the following error while running bundle install

Ruby 2.3 is installed but ruby 2.2.2 is being used through RVM - rvm use 2.2.2 but i dont think thats where the issue is

The issues are included below

jon220@jon220-XPS-12-9Q33:~/Desktop/em-client$ bundle install
    Fetching gem metadata from https://rubygems.org/.............
    Fetching version metadata from https://rubygems.org/...
    Fetching dependency metadata from https://rubygems.org/..
    Using rake 11.1.1
    Using i18n 0.7.0
    Using json 1.8.3
    Using minitest 5.8.4
    Using thread_safe 0.3.5
    Using builder 3.2.2
    Using erubis 2.7.0
    Using mini_portile2 2.0.0
    Using rack 1.6.4
    Using mime-types 2.99.1
    Using arel 6.0.3
    Using bcrypt 3.1.11
    Using coderay 1.1.1
    Using debug_inspector 0.0.2
    Using thor 0.19.1
    Using bundler 1.13.1
    Using concurrent-ruby 1.0.1
    Using byebug 8.2.2
    Using chronic 0.10.2
    Using coffee-script-source 1.10.0
    Using execjs 2.6.0
    Using orm_adapter 0.5.0
    Using multi_json 1.11.2
    Using tilt 2.0.2
    Using multi_xml 0.5.5
    Using method_source 0.8.2
    Installing pg 0.18.4 with native extensions
    Using slop 3.6.0
    Using puma 3.2.0
    Using rails_serve_static_assets 0.0.5
    Using rails_stdout_logging 0.0.4
    Using sass 3.4.21
    Using spring 1.6.4
    Using sqlite3 1.3.11
    Using rdoc 4.2.2
    Using tzinfo 1.2.2
    Using nokogiri 1.6.7.2
    Using rack-test 0.6.3
    Using warden 1.2.6
    Using mail 2.6.3
    Using better_errors 2.1.1
    Using binding_of_caller 0.7.2
    Using sprockets 3.5.2
    Using whenever 0.9.7
    Using coffee-script 2.4.1
    Using uglifier 2.7.2
    Using rollbar 2.12.0
    Using httparty 0.13.7
    Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /home/jon220/.rvm/rubies/ruby-2.2.2/bin/ruby -r
    ./siteconf20160915-12645-sijcbm.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=/home/jon220/.rvm/rubies/ruby-2.2.2/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

    extconf failed, exit code 1

    Gem files will remain installed in
    /home/jon220/.rvm/gems/ruby-2.2.2/gems/pg-0.18.4 for inspection.
    Results logged to
    /home/jon220/.rvm/gems/ruby-2.2.2/extensions/x86_64-linux/2.2.0/pg-0.18.4/gem_make.out

    An error occurred while installing pg (0.18.4), and Bundler cannot
    continue.
    Make sure that `gem install pg -v '0.18.4'` succeeds before bundling.

Any help would be greatly appreciated

like image 515
code_legend Avatar asked Sep 15 '16 12:09

code_legend


2 Answers

Install the postgresql-devel package, this will solve the issue

sudo apt-get install libpq-dev
like image 161
Navin Avatar answered Nov 15 '22 15:11

Navin


For MacOS you need to install libpq and add it to the PATH:

brew install libpq
echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.zshrc
like image 21
Alex Filatov Avatar answered Nov 15 '22 15:11

Alex Filatov