I am trying to bundle install, but, for some strange reason, the pg gem is returning the following error on install:
$ gem install pg -v '0.18.4'
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/username/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20151221-23315-1tkv3fd.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
--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/username/.rvm/rubies/ruby-2.2.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
extconf failed, exit code 1
Gem files will remain installed in /Users/username/.rvm/gems/ruby-2.2.1/gems/pg-0.18.4 for inspection.
Results logged to /Users/username/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-15/2.2.0/pg-0.18.4/gem_make.out
Can anyone please help me install this gem and make my bundle finish successfully?
You should probably install the PostgreSQL development libraries.
If you're on Ubuntu this will help:
sudo apt-get install libpq-dev
On a Mac:
brew install postgresql
You need to configure pg correctly.
Run:
bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/(YOUR POSTGRES VERSION)/bin/pg_config
Then try to run bundle:
bundle install
If the PostgreSQL client library is installed, then you need to tell gem where to look for the include files, which it does by asking pg_config. I use a little shell file to make it easier for gem to find that utility:
#!/bin/sh -x
PATH=/Library/PostgreSQL/9.4/bin:$PATH
gem install pg $#
You could also manually adjust your PATH to always include the PostgreSQL bin directory, which should fix the problem permanently.
If you upgrade your PostgreSQL that path will change, so you might need to reinstall pg and/or change your PATH setting.
Once pg is installed, further upgrades to the gem will be able to install without rerunning the script.
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'm using/I want to use Postgresql as database, but when I type "bundle install" or "bundle update", I get this error, what do I do to fix this? :)
Installing pg (0.17.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p392/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-p392/bin/ruby
--with-pg
--without-pg
--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
Gem files will remain installed in /Users/rsvmrk/.bundler/tmp/22196/gems/pg-0.17.1 for inspection.
Results logged to /Users/rsvmrk/.bundler/tmp/22196/gems/pg-0.17.1/ext/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
Any suggestions?
Looks like you are missing pre-requisite libraries.
sudo apt-get install libpq-dev postgresql-devel
Then install pg
gem install pg
For those on OS X, I recommend using home-brew to install:
brew install postgresql
More info at Homebrew's site, if you're not already a user, including how to set it up.
in order to communicate with a PostgreSQL database backend you need the libpq-dev package.
sudo apt-get install libpq-dev
then continue the package installation
gem install pg
After installing OS X Mavericks, I cannot get an old Rails 4 app to work. The main issue seems to be trouble installing the pg gem:
Christophers-MacBook-Pro-2:DataSquid christopherspears$ gem install pg -v '0.17.1'
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Christophers-MacBook-Pro-2:DataSquid christopherspears$ sudo gem install pg -v '0.17.1'
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--with-pg
--without-pg
--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}/
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/pg-0.17.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/pg-0.17.1/ext/gem_make.out
I am not sure what the issue is. I did install the command line tools for OS X Mavericks for Xcode (late October 2013), but that did not resolve the issue.
As this question recommends, the easiest way is to install Postgres.app and then run
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
to install the pg gem using the Postgres.app pg_config.
I'm using/I want to use Postgresql as database, but when I type "bundle install" or "bundle update", I get this error, what do I do to fix this? :)
Installing pg (0.17.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p392/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-p392/bin/ruby
--with-pg
--without-pg
--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
Gem files will remain installed in /Users/rsvmrk/.bundler/tmp/22196/gems/pg-0.17.1 for inspection.
Results logged to /Users/rsvmrk/.bundler/tmp/22196/gems/pg-0.17.1/ext/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
Any suggestions?
Looks like you are missing pre-requisite libraries.
sudo apt-get install libpq-dev postgresql-devel
Then install pg
gem install pg
For those on OS X, I recommend using home-brew to install:
brew install postgresql
More info at Homebrew's site, if you're not already a user, including how to set it up.
in order to communicate with a PostgreSQL database backend you need the libpq-dev package.
sudo apt-get install libpq-dev
then continue the package installation
gem install pg
I'm suddenly running into this issue when running 'bundle install'. Everything seems to be installing correctly, but then I run into an issue with 'pg', as so many others seem to do. As the message says, I try running 'gem install pg - '0.12.2'' but it still fails.
I'm on Snow Leopard 10.6 and this is the error I'm getting:
Installing pg (0.12.2) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/thomaskim/.rvm/rubies/ruby-1.9.3-p327/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
--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/thomaskim/.rvm/rubies/ruby-1.9.3-p327/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
Gem files will remain installed in /Users/thomaskim/.bundler/tmp/1336/gems/pg-0.12.2 for inspection.
Results logged to /Users/thomaskim/.bundler/tmp/1336/gems/pg-0.12.2/ext/gem_make.out
An error occurred while installing pg (0.12.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.12.2'` succeeds before bundling.
First you need to make sure you have command line tools (package for Xcode) installed. Since you're on old version of OSX - you will have to research how to do that.
Than, using homebrew install postgress
brew install postgres
After that, everything should bundle with no issues.
It appears that you do not have postgres installed properly. I got a similar error when I was trying to install a pg module with npm. It disappeared after installing postgres properly.
Here's a link to download: http://www.postgresql.org/download/macosx/
If you run rails on your machine only in dev mode and use sql lite for that, you need don't need to install the production bundles.
So if your gemfile looke like that:
group :production do
gem 'pg'
end
Try installing the bundles with the following command:
gem install --without production