I'm trying to combine a Rails app and PostgreSQL on the same Azure virtual machine.
I installed PostgreSQL 9.5 following this guide and it seems to give no problems by itself. Now the problem is, I cannot install the pg gem. Specifically, running the command gem install pg -v '0.19.0', it gives me the following error:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/pg-0.19.0/ext
/usr/bin/ruby2.3 -r ./siteconf20170122-18144-1ee3id1.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/bin/$(RUBY_BASE_NAME)2.3
--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:
/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/pg-0.19.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/pg-0.19.0 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/pg-0.19.0/gem_make.out
Any help is really appreciated. Cheers
What is the response of which pg_config
If it is something like:
/usr/bin/which: no pg_config in...
Try installing again with below command:
sudo apt-get install postgresql-devel
As simple as it was, I just needed to install postgresql-server-dev-9.5 on my Azure Ubuntu VM. I just overlooked the error log :D
Related
Iam trying to set up a rails project which has ruby 2.2.3 and rails version 4.2.7.1. It uses PostgreSQL as the database . I can see gem 'pg' entry in the GemFile. I did bundle install to install the dependencies, but when it came to installing pg gem , it is giving me the following error. I dont have postgreSQL installed on my ubuntu 18.04 LTS system. Could this be the reason why iam getting this error. Please help. Error that i am getting:
**
**Fetching pg 1.2.3
Installing pg 1.2.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/pc-123/.rvm/gems/ruby-2.2.3/gems/pg-1.2.3/ext
/home/pc-123/.rvm/rubies/ruby-2.2.3/bin/ruby -I /home/pc-123/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0 -r ./siteconf20200822-841-6si3xn.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/pc-123/.rvm/rubies/ruby-2.2.3/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
**
You must install the libpq-dev package. You are using Ubuntu so:
sudo apt install libpq-dev
It would be smart to have PostGreSQL installed.
This depends on what Ruby version is your interpreter using. A mismatch there and you can run into problems. Using the same version will fix your issue.
I tried to install pg gem. But it produce the following error. Can anyone help me to solve this problem ?
root#localhost:/home/rails/Project# gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/pg-0.18.4/ext
/usr/bin/ruby2.3 -r ./siteconf20160908-9582-xu3pmx.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/bin/$(RUBY_BASE_NAME)2.3
--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:
/var/lib/gems/2.3.0/extensions/x86-linux/2.3.0/pg-0.18.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/pg-0.18.4 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86-linux/2.3.0/pg-0.18.4/gem_make.out
root#localhost:/home/rails/Project#
The error says:
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 ***
It's a good skill to read errors from the building native extensions step of a gem installation. Native extensions frequently depend on system libraries which won't be automatically installed.
you need to run apt-get install libpq-dev
See here for a good guide to install Postgres on Ubuntu - there are more steps than just installing the gem. You'll need to configure a postgres user account as well.
When trying to run bundle install I get the following error
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/seque1990/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/pg-0.18.4/ext
/Users/seque1990/.rbenv/versions/2.2.2/bin/ruby -r ./siteconf20160117-46131-1dmnnnq.rb extconf.rb --with-pg-config=/opt/local/lib/postgresql91/bin/pg_config
Using config values from /opt/local/lib/postgresql91/bin/pg_config
sh: /opt/local/lib/postgresql91/bin/pg_config: No such file or directory
sh: /opt/local/lib/postgresql91/bin/pg_config: No such file or directory
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=/Users/seque1990/.rbenv/versions/2.2.2/bin/$(RUBY_BASE_NAME)
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-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:
/Users/seque1990/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0-static/pg-0.18.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/seque1990/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/pg-0.18.4 for inspection.
Results logged to /Users/seque1990/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0-static/pg-0.18.4/gem_make.out
After getting that I did brew install postgresql but it tells me that it is already installed but not linked.
Then I tried brew link postgresql but it tells me:
Error: Could not symlink share/man/man3/SPI_connect.3
/usr/local/share/man/man3 is not writable.
Not sure how to proceed. :(
If your using ubuntu machine then,
sudo apt-get install postgresql
sudo apt-get install libpq-dev
And Then,gem install pg
For oSx, you need to specify the pg_config path
gem install pg -- --with-pg-config=`which pg_config`
which pg_config gives you the file path where it is installed.
I am trying to migrate from Heroku to AWS
I have created a stack with the following custom JSON:
{
"deploy": {
"appname": {
"database": {
"username": "myuser",
"password": "password",
"database": "databasename",
"host": "rdsendpoint",
"port": "5432",
"adapter": "postgresql"
}
}
}
}
I have created a RDS postgres DB and a Rails App Server. I have created an instance and an App linked to my git repository.
However the instance fails to start and I get this error message:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby 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=/usr/local/bin/ruby
--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}/
extconf failed, exit code 1
Gem files will remain installed in /home/deploy/.bundler/authorship/ruby/2.0.0/gems/pg-0.18.2 for inspection.
Results logged to /home/deploy/.bundler/authorship/ruby/2.0.0/extensions/x86_64-linux/2.0.0/pg-0.18.2/gem_make.out
An error occurred while installing pg (0.18.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.2'` succeeds before bundling.
How can I fix this on AWS, since I cannot access the instance through ssh as it fails to start.
I tried to add a postgres-devel package to the layer, but I got a different error, seems that the package is no longer available.
Since the instance doesn't have this package libpq-dev do
sudo apt-get install libpq-dev
So that pg gem can be installed.
Here's the description of libpq-dev:
Header files and static library for compiling C programs to link
with the libpq library in order to communicate with a PostgreSQL
database backend.
The pg gem is a native extension that wraps the libpq library.
P.S I recently ran into this problem, I got some explanation on other group.
I'm on Ubuntu 10.04, how to fix this error?
When I use bundle install command, this install the necessary gems for run the app with rails s.
But "bundle install" command fails too.
I don´t understand the console prompt, can somebody help me?
antonio#antonio-desktop:~/Descargas/ecozap$ gem install pg -v 0.15.1
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p484/bin/ruby 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=/usr/local/rvm/rubies/ruby-1.9.3-p484/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
extconf failed, exit code 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p484/gems/pg-0.15.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p484/extensions/x86-linux/1.9.1/pg-0.15.1/gem_make.out
When I used the sudo apt-get install libpq-dev, I´m getting the following error:
antonio # antonio-desktop: ~ / Downloads / ECOZAP $ sudo apt-get install libpq-dev
[sudo] password for antonio:
E: Failed to lock / var / lib / dpkg / lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/ var / lib / dpkg /), maybe there is another process using it?
All you have to do is close any other package manager that is locking apt and install libpq-dev again.