Question

"gem install pg" not working

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?


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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

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’