Brian Moore Brian Moore - 24 days ago 11
Ruby Question

gem pg not installing

So I had to reinitialize a project after my pc crashed and am in the process of reinstalling all my gems on ruby. Unfortunately when I run bundle install I get the following error.

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

current directory: /usr/lib/ruby/gems/2.3.0/gems/pg-0.21.0/ext
/usr/bin/ruby2.3 -r ./siteconf20170925-462-dsymf.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /usr/lib/ruby/gems/2.3.0/gems/pg-0.21.0
for inspection.
Results logged to /usr/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/pg-

If someone could give me a point in the right direction it would be greatly appreciated.

Answer Source

Try this

 sudo sh -c "echo 'deb xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
 wget --quiet -O - | sudo apt-key add -
 sudo apt-get update
 sudo apt-get install postgresql-common
 sudo apt-get install postgresql-9.5 libpq-dev

gem install pg

Recommend with ruby 2.4.2