简体   繁体   中英

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-
0.21.0/gem_make.out

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

Try this

 sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
 wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | 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

Cheers!

sudo apt-get install postgresql
sudo apt-get install libpq-dev

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM