I am trying to install the 'pg' gem and get the following error:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/thomas/.rvm/gems/ruby-2.7.1/gems/pg-1.2.3/ext
/usr/share/rvm/rubies/ruby-2.7.1/bin/ruby -I
/usr/share/rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0 -r
./siteconf20200423-27933-r303r1.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
You need to install postgresql-server-dev-X.Y for building a server-side
extension or libpq-dev for building a client-side application.
You need to install postgresql-server-dev-X.Y for building a server-side
extension or libpq-dev for building a client-side application.
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/share/rvm/rubies/ruby-2.7.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:
/home/thomas/.rvm/gems/ruby-2.7.1/extensions/x86_64-linux/2.7.0/pg-1.2.3/mkmf.log
extconf failed, exit code 1
many SO searches suggest
sudo apt-get install libpq-dev
but this gives
Err:1 http://apt.postgresql.org/pub/repos/apt xenial-pgdg/main amd64 libpq5 amd64 11.4-1.pgdg16.04+1
404 Not Found [IP: 87.238.57.227 80]
Err:2 http://apt.postgresql.org/pub/repos/apt xenial-pgdg/main amd64 libpq-dev amd64 11.4-1.pgdg16.04+1
404 Not Found [IP: 87.238.57.227 80]
E: Failed to fetch http://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-11/libpq5_11.4-1.pgdg16.04+1_amd64.deb 404 Not Found [IP: 87.238.57.227 80]
E: Failed to fetch http://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-11/libpq-dev_11.4-1.pgdg16.04+1_amd64.deb 404 Not Found [IP: 87.238.57.227 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
and running the suggested
apt-get update --fix-missing
gives the same error as above. Any ideas? I have seen a lot of posts with the same problem, offering usually similar solutions, but they just dont seem to be working here. Thanks in advance
sudo apt-get install libpq-dev
I tried many solutions, but installing Postgres from its official site was what worked for me.
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.