Report this

What is the reason for this report?

"gem install pg" not working

Posted on October 17, 2013

Hello,

I’m trying to install the ruby pg gem and I had this exact problem on my mac because of 64 bit architecture. The solution was something like “sudo env ARCHFLAGS=”-arch x86_64" gem install pg" (http://stackoverflow.com/questions/10344821/gem-install-pg-doesnt-work-on-osx-lion). I suspect it is the same problem since my server is running Ubuntu 12.04 x64.

The command “gem install pg” doesn’t work and gives me the following error: <pre> Fetching: pg-0.17.0.gem (100%) Building native extensions. This could take a while… ERROR: Error installing pg: ERROR: Failed to build gem native extension.

/usr/local/rvm/rubies/ruby-2.0.0-p247/bin/ruby 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. </pre> As a warning, I am a straight up noob at this stuff.

Any thoughts?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

After a day fighting, I found out through the mkmf.log that the command “ld -lgmp” was failing. So I installed the libgmp-dev package and now it works.

found a solution: <br> <br>use these commands http://stackoverflow.com/questions/4564117/sudo-gem-install-pg-wont-work <br> <br>then ‘gem install pg should work’

On Ubuntu $ sudo apt-get install postgresql-client libpq5 libpq-dev $ sudo gem install pg

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.