Ruby-pg gem won't compile

Hi list,

I've had some success with Chef (solo) so far, using knife-solo. I could
already provision a server with nginx and a jekyll blog...

However, I got lost when it came to setup my rack app (padrino). I'm
writing my own recipe, like I did with the jekyll one, and using a couple
of other recipes for other components (postgres, runit, unicorn,
application, application-ruby).

Everything goes well until I reach the point where bundle install tries to
install the ruby-pg gem for the padrino app. It fails with:

Installing pg (0.14.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

    /opt/chef/embedded/bin/ruby extconf.rb

checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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.

I have libpq installed, but it just doesn't pick it up. I tried the
chef-rvm cookbook (GitHub - sous-chefs/rvm: Development repository for the rvm cookbook), and tried to
install rvm on the deploy user (I'm creating a deploy user that the app
should be deploy on and ran from), but it also doesn't pick it up, and the
gem_package monkeypatch, that is supposed to allow gems to be installed in
the rvm ruby, fails.

I'm totally lost. Could someone shed some light on it? I'd be grateful!

Cheers,

  • Marcelo.

Hi Marcelo,

you might have run into http://tickets.opscode.com/browse/COOK-1406

The workaround mentioned in this comment worked for me:
http://tickets.opscode.com/browse/COOK-1406?focusedCommentId=28255&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-28255

HTH, Torben

On Sat, Nov 24, 2012 at 6:52 AM, Marcelo de Moraes Serpa <
celoserpa@gmail.com> wrote:

Hi list,

I've had some success with Chef (solo) so far, using knife-solo. I could
already provision a server with nginx and a jekyll blog...

However, I got lost when it came to setup my rack app (padrino). I'm
writing my own recipe, like I did with the jekyll one, and using a couple
of other recipes for other components (postgres, runit, unicorn,
application, application-ruby).

Everything goes well until I reach the point where bundle install tries to
install the ruby-pg gem for the padrino app. It fails with:

Installing pg (0.14.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

    /opt/chef/embedded/bin/ruby extconf.rb

checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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.

I have libpq installed, but it just doesn't pick it up. I tried the
chef-rvm cookbook (GitHub - sous-chefs/rvm: Development repository for the rvm cookbook), and tried to
install rvm on the deploy user (I'm creating a deploy user that the app
should be deploy on and ran from), but it also doesn't pick it up, and the
gem_package monkeypatch, that is supposed to allow gems to be installed in
the rvm ruby, fails.

I'm totally lost. Could someone shed some light on it? I'd be grateful!

Cheers,

  • Marcelo.

It'll be looking for libpq in some set of library paths - but your libpq
isn't in one of those paths.
Find libpq - figure out what library paths it's using (it probably tells
you at the top) and then put the two together.
You could symlink the library or add a library path when running the
configure.

cheers,
Edward

On Fri, Nov 23, 2012 at 9:52 PM, Marcelo de Moraes Serpa <
celoserpa@gmail.com> wrote:

Hi list,

I've had some success with Chef (solo) so far, using knife-solo. I could
already provision a server with nginx and a jekyll blog...

However, I got lost when it came to setup my rack app (padrino). I'm
writing my own recipe, like I did with the jekyll one, and using a couple
of other recipes for other components (postgres, runit, unicorn,
application, application-ruby).

Everything goes well until I reach the point where bundle install tries to
install the ruby-pg gem for the padrino app. It fails with:

Installing pg (0.14.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

    /opt/chef/embedded/bin/ruby extconf.rb

checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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.

I have libpq installed, but it just doesn't pick it up. I tried the
chef-rvm cookbook (GitHub - sous-chefs/rvm: Development repository for the rvm cookbook), and tried to
install rvm on the deploy user (I'm creating a deploy user that the app
should be deploy on and ran from), but it also doesn't pick it up, and the
gem_package monkeypatch, that is supposed to allow gems to be installed in
the rvm ruby, fails.

I'm totally lost. Could someone shed some light on it? I'd be grateful!

Cheers,

  • Marcelo.

@torben, thanks. I have seen this workaround, but wanted to try something
else. Any way to include that in the cook process? Or did you run it
manually? I wouldn't want to have to run it manually though, since that
pretty much defeats the purpose of Chef.

@edward - that pretty much means I'll have to hack into the
postgresql-server recipe right? I'll play with it.

Lastly, does anyone know why this still fails? This is a pretty critical
bug for such an important cookbook.

Thanks!

  • Marcelo.

On Sat, Nov 24, 2012 at 10:20 AM, Edward Sargisson esarge@pobox.com wrote:

It'll be looking for libpq in some set of library paths - but your libpq
isn't in one of those paths.
Find libpq - figure out what library paths it's using (it probably tells
you at the top) and then put the two together.
You could symlink the library or add a library path when running the
configure.

cheers,
Edward

On Fri, Nov 23, 2012 at 9:52 PM, Marcelo de Moraes Serpa <
celoserpa@gmail.com> wrote:

Hi list,

I've had some success with Chef (solo) so far, using knife-solo. I could
already provision a server with nginx and a jekyll blog...

However, I got lost when it came to setup my rack app (padrino). I'm
writing my own recipe, like I did with the jekyll one, and using a couple
of other recipes for other components (postgres, runit, unicorn,
application, application-ruby).

Everything goes well until I reach the point where bundle install tries
to install the ruby-pg gem for the padrino app. It fails with:

Installing pg (0.14.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

    /opt/chef/embedded/bin/ruby extconf.rb

checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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.

I have libpq installed, but it just doesn't pick it up. I tried the
chef-rvm cookbook (GitHub - sous-chefs/rvm: Development repository for the rvm cookbook), and tried to
install rvm on the deploy user (I'm creating a deploy user that the app
should be deploy on and ran from), but it also doesn't pick it up, and the
gem_package monkeypatch, that is supposed to allow gems to be installed in
the rvm ruby, fails.

I'm totally lost. Could someone shed some light on it? I'd be grateful!

Cheers,

  • Marcelo.

Nope, not manually. I have update my postgresql::client recipe like so to
install from source when we are on an ubuntu 12.04 omnibus install:

Cheers, Torben

On Sat, Nov 24, 2012 at 6:27 PM, Marcelo de Moraes Serpa <
celoserpa@gmail.com> wrote:

@torben, thanks. I have seen this workaround, but wanted to try something
else. Any way to include that in the cook process? Or did you run it
manually? I wouldn't want to have to run it manually though, since that
pretty much defeats the purpose of Chef.

@edward - that pretty much means I'll have to hack into the
postgresql-server recipe right? I'll play with it.

Lastly, does anyone know why this still fails? This is a pretty critical
bug for such an important cookbook.

Thanks!

  • Marcelo.

On Sat, Nov 24, 2012 at 10:20 AM, Edward Sargisson esarge@pobox.comwrote:

It'll be looking for libpq in some set of library paths - but your libpq
isn't in one of those paths.
Find libpq - figure out what library paths it's using (it probably tells
you at the top) and then put the two together.
You could symlink the library or add a library path when running the
configure.

cheers,
Edward

On Fri, Nov 23, 2012 at 9:52 PM, Marcelo de Moraes Serpa <
celoserpa@gmail.com> wrote:

Hi list,

I've had some success with Chef (solo) so far, using knife-solo. I could
already provision a server with nginx and a jekyll blog...

However, I got lost when it came to setup my rack app (padrino). I'm
writing my own recipe, like I did with the jekyll one, and using a couple
of other recipes for other components (postgres, runit, unicorn,
application, application-ruby).

Everything goes well until I reach the point where bundle install tries
to install the ruby-pg gem for the padrino app. It fails with:

Installing pg (0.14.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

    /opt/chef/embedded/bin/ruby extconf.rb

checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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.

I have libpq installed, but it just doesn't pick it up. I tried the
chef-rvm cookbook (GitHub - sous-chefs/rvm: Development repository for the rvm cookbook), and tried to
install rvm on the deploy user (I'm creating a deploy user that the app
should be deploy on and ran from), but it also doesn't pick it up, and the
gem_package monkeypatch, that is supposed to allow gems to be installed in
the rvm ruby, fails.

I'm totally lost. Could someone shed some light on it? I'd be grateful!

Cheers,

  • Marcelo.

Hi Torben,

Thanks for sharing that! I'll try that out.

Cheers,

  • Marcelo.

On Sun, Nov 25, 2012 at 4:37 AM, Torben Knerr ukio@gmx.de wrote:

Nope, not manually. I have update my postgresql::client recipe like so to
install from source when we are on an ubuntu 12.04 omnibus install:
updated postgresql::client with workaround for COOK-1406 (compile from source) · GitHub

Cheers, Torben

On Sat, Nov 24, 2012 at 6:27 PM, Marcelo de Moraes Serpa <
celoserpa@gmail.com> wrote:

@torben, thanks. I have seen this workaround, but wanted to try
something else. Any way to include that in the cook process? Or did you run
it manually? I wouldn't want to have to run it manually though, since that
pretty much defeats the purpose of Chef.

@edward - that pretty much means I'll have to hack into the
postgresql-server recipe right? I'll play with it.

Lastly, does anyone know why this still fails? This is a pretty critical
bug for such an important cookbook.

Thanks!

  • Marcelo.

On Sat, Nov 24, 2012 at 10:20 AM, Edward Sargisson esarge@pobox.comwrote:

It'll be looking for libpq in some set of library paths - but your libpq
isn't in one of those paths.
Find libpq - figure out what library paths it's using (it probably tells
you at the top) and then put the two together.
You could symlink the library or add a library path when running the
configure.

cheers,
Edward

On Fri, Nov 23, 2012 at 9:52 PM, Marcelo de Moraes Serpa <
celoserpa@gmail.com> wrote:

Hi list,

I've had some success with Chef (solo) so far, using knife-solo. I
could already provision a server with nginx and a jekyll blog...

However, I got lost when it came to setup my rack app (padrino). I'm
writing my own recipe, like I did with the jekyll one, and using a couple
of other recipes for other components (postgres, runit, unicorn,
application, application-ruby).

Everything goes well until I reach the point where bundle install tries
to install the ruby-pg gem for the padrino app. It fails with:

Installing pg (0.14.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

    /opt/chef/embedded/bin/ruby extconf.rb

checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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.

I have libpq installed, but it just doesn't pick it up. I tried the
chef-rvm cookbook (GitHub - sous-chefs/rvm: Development repository for the rvm cookbook), and tried to
install rvm on the deploy user (I'm creating a deploy user that the app
should be deploy on and ran from), but it also doesn't pick it up, and the
gem_package monkeypatch, that is supposed to allow gems to be installed in
the rvm ruby, fails.

I'm totally lost. Could someone shed some light on it? I'd be grateful!

Cheers,

  • Marcelo.

Just a heads up on what worked for me. I didn't have to modify the
postgresql cookbook, the problem was really with the Ruby distribution that
Chef was using.

I started using this cookbook - [
chef-solo/cookbooks/ruby_installer at master · map7/chef-solo · GitHub] -
to install Ruby 1.9.3-p317 system wide (that means that Chef is using it
too. I tried using rvm but it's just a pain in the *ss on production
systems, it seems). and now the ruby-pg gem compiles when bundler install
is called for my Padrino application. Everything is working great now :slight_smile:

Hope that helps someone,

Cheers,

  • Marcelo.

On Sun, Nov 25, 2012 at 5:11 PM, Marcelo de Moraes Serpa <
celoserpa@gmail.com> wrote:

Hi Torben,

Thanks for sharing that! I'll try that out.

Cheers,

  • Marcelo.

On Sun, Nov 25, 2012 at 4:37 AM, Torben Knerr ukio@gmx.de wrote:

Nope, not manually. I have update my postgresql::client recipe like so to
install from source when we are on an ubuntu 12.04 omnibus install:
updated postgresql::client with workaround for COOK-1406 (compile from source) · GitHub

Cheers, Torben

On Sat, Nov 24, 2012 at 6:27 PM, Marcelo de Moraes Serpa <
celoserpa@gmail.com> wrote:

@torben, thanks. I have seen this workaround, but wanted to try
something else. Any way to include that in the cook process? Or did you run
it manually? I wouldn't want to have to run it manually though, since that
pretty much defeats the purpose of Chef.

@edward - that pretty much means I'll have to hack into the
postgresql-server recipe right? I'll play with it.

Lastly, does anyone know why this still fails? This is a pretty critical
bug for such an important cookbook.

Thanks!

  • Marcelo.

On Sat, Nov 24, 2012 at 10:20 AM, Edward Sargisson esarge@pobox.comwrote:

It'll be looking for libpq in some set of library paths - but your
libpq isn't in one of those paths.
Find libpq - figure out what library paths it's using (it probably
tells you at the top) and then put the two together.
You could symlink the library or add a library path when running the
configure.

cheers,
Edward

On Fri, Nov 23, 2012 at 9:52 PM, Marcelo de Moraes Serpa <
celoserpa@gmail.com> wrote:

Hi list,

I've had some success with Chef (solo) so far, using knife-solo. I
could already provision a server with nginx and a jekyll blog...

However, I got lost when it came to setup my rack app (padrino). I'm
writing my own recipe, like I did with the jekyll one, and using a couple
of other recipes for other components (postgres, runit, unicorn,
application, application-ruby).

Everything goes well until I reach the point where bundle install
tries to install the ruby-pg gem for the padrino app. It fails with:

Installing pg (0.14.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

    /opt/chef/embedded/bin/ruby extconf.rb

checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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.

I have libpq installed, but it just doesn't pick it up. I tried the
chef-rvm cookbook (GitHub - sous-chefs/rvm: Development repository for the rvm cookbook), and tried to
install rvm on the deploy user (I'm creating a deploy user that the app
should be deploy on and ran from), but it also doesn't pick it up, and the
gem_package monkeypatch, that is supposed to allow gems to be installed in
the rvm ruby, fails.

I'm totally lost. Could someone shed some light on it? I'd be grateful!

Cheers,

  • Marcelo.