13

I don't know if this question belongs here, but I'll take a shot. Hi. I'm running ubuntu 11.10 dual-boot with windows vista on my machine. On Ubuntu, I've installed RVM, rails gem, & PostgreSQL (the postgres server, client, & other packages like libpq5, because I installed it via Software Center).

I'm trying to deploy my app on heroku, but seems like i need to install pg gem. I tried to install it, but got this error instead:

ERROR: Failed to build gem native extension.

/home/pcr/.rvm/rubies/ruby-1.9.3-p0/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... * extconf.rb failed *

After searching google & stackoverflow for a while, many people said that libpq-dev has to be installed. I tried, via software center but fail do to unmet dependencies. I tried via apt-get, it said that I need libkrb5-dev and krb5-multidev. I tried sudo apt-get install libpq-dev libkrb5-dev krb5-multidev, and got this:

The following packages have unmet dependencies: krb5-multidev :

Depends: libkrb5-3 (= 1.9.1+dfsg-1ubuntu1) but 1.9.1+dfsg-1ubuntu2.1 is to be installed

Depends: libk5crypto3 (= 1.9.1+dfsg-1ubuntu1) but 1.9.1+dfsg-1ubuntu2.1 is to be installed

Depends: libgssapi-krb5-2 (= 1.9.1+dfsg-1ubuntu1) but 1.9.1+dfsg-1ubuntu2.1 is to be installed E: Unable to correct problems, you have held broken packages.

But I already have libkrb5-3, libk5crypto3, and libgssapi-krb5-2 (all with version 1.9.1+dfsg-1ubuntu2.1) on my system! I think maybe the version needed is 1.9.1+dfsg-1ubuntu1. So, maybe I have to remove the 1.9.1+dfsg-1ubuntu2.1 packages first. Do you think it's safe for me to remove it? I tried to remove one of them, but software center warns me that it will also remove postgres, openssl-client, smbclient, cups, and many other packages.

What should I do to resolve this? And, is pg gem really necessary to be installed on my local machine to create rails app with postgres as the dbms? Is there a way to "hand over" the responsibility to include pg gem to heroku instead?

2 Answers 2

33

I got same issue today. I followed message You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. So installed libpq-dev and bundle rails app again and the error disappeared.

$ sudo apt-get install libpq-dev
$ bundle install
1
  • 2
    This is a better solution if you want to mirror postgres on your development machine, worked for me. Sep 7, 2012 at 18:11
8

The real solution is, as correctly pointed out by Amit Patel, to install libpq-dev


Here is a workaround if you were unable to setup pg at you development machine. You can use sqlite in your local machine and pg in Heroku. Here is what you should have in your Gemfile

group :production do
  gem 'pg'
end

group :development, :test do
  gem 'sqlite3'
end

And use this command for installing bundle to ignore production gems:

bundle install --without production

Please keep in mind that not having same environment in production and development machines is not recommended.

8
  • Yup, this is the correct answer. +1, I do this all the time now.
    – jrg
    Feb 19, 2012 at 22:06
  • @jrg do you experience some problem by doing this? I ask because heroku says "it's not recommended".
    – PatrixCR
    Feb 20, 2012 at 2:03
  • Heroku doesn't recommend it because generally you want to have the same development env as the server - however, as long as you are using ActiveRecord or DataMapper and you're not writing raw SQL, you should be fine 99% of the time. :)
    – jrg
    Feb 20, 2012 at 2:30
  • 1
    @PatrixCR nope, heroku will do that for you.
    – jrg
    Feb 20, 2012 at 10:39
  • 1
    Using sqlite is workaround. What is the solution then?
    – Amit Patel
    Aug 30, 2012 at 5:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .