Provide better diagnostics for installation problems

Issue #89 closed
James Gifford
created an issue

Currently, if you install the gem on Ubuntu, it fails to compile the native extensions. This is fixed if you install the libpq-dev package.

Please make it obvious that it needs to be installed, otherwise it will fail.

Comments (8)

  1. Anonymous

    First off, THANKS for the great work in the pg gem.

    Interesting request. Many people hit this problem. In my recent blog post ( I point to this problem and I am sure there must be another 100 blog posts pointing this out.

    Is there a structural way for a gem to explicitly mention the dependency on system libraries (depending on the exact operating system it is turning on; so it could say:

    if dev_lib_missing
      problem_report =
        case OperatingSystem
        when /Ubuntu|Debian/
          "Install the libpq-dev package"
        when /RedHat/
           "Install ...
        when /Darwin/
           "Install ...
          "Install the libraries with the postgresql header files"
  2. Michael Granger repo owner

    @James Gifford: While I'd ideally like to provide good diagnostics for everyone who might want to use the library, mentioning prerequisites for every conceivable packaging strategy isn't realistic. I'd argue that if someone is installing a gem on a system that breaks software up into -dev and non-dev variants, they should either use the native packaging system to do it (as it's capable of expressing its own dependencies), or know enough about their own systems that they can responsibly install software outside of it without needing to be told that they're missing headers or whatever.

    @anonymous: There isn't any built-in way to do so that I know of, but one of my goals for the next release is to provide better diagnostics for installation problems. Part of that will be generating a better error message if the libraries/headers for libpq aren't found. While I don't think providing help tailored to every possible installation architecture/platform/OS is realistic, I can at the very least mention that it might be in a "-dev" package.

    Thanks for the blog post, too! I can't possibly track down everyone who's having a problem, and people seem reluctant to actually ask the maintainer for help, so some useful advice for people googling "Can't find the 'libpq-fe.h header" or whatever will solve a lot of peoples' problems.

  3. Michael Granger repo owner

    Given that this gem now has a binary gem, I'm going to close this. Patches will of course be accepted that make it easier to install or diagnose installation problems on all platforms Ruby runs on.

  4. Log in to comment