John John - 1 year ago 347
Ruby Question

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
Fetching version metadata from
Fetching dependency metadata from
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
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
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:

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

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

Any help would be greatly appreciated

Answer Source

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

sudo apt-get install libpq-dev
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download