postgresql: pg gem fails to compile with chef 12.0

Just ran into this issue when my omnibus plugin for vagrant upgraded the chef-client from 11.16 to 12.0.

Fixed by pinning to last known 11.x version that worked.

config.omnibus.chef_version = '11.16.4'

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 2
  • Comments: 93 (8 by maintainers)

Commits related to this issue

Most upvoted comments

The solution is: In the cookbook where you include the postgresql::ruby recipe add following at the top:

node.default['build-essential']['compile_time'] = true
include_recipe 'build-essential'

I’m still seeing the issue, two. ubuntu 14.04 and 12.04 chef 12.0.3 postgresql cookbok 3.4.16

Recipe: postgresql::ruby
* chef_gem[pg] action install

  ================================================================================
  Error executing action `install` on resource 'chef_gem[pg]'
  ================================================================================

  Mixlib::ShellOut::ShellCommandFailed
  ------------------------------------
  Expected process to exit with [0], but received '1'
  ---- Begin output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "0.18.1" ----
  STDOUT: Building native extensions.  This could take a while...
  STDERR: ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

      /opt/chef/embedded/bin/ruby -r ./siteconf20150224-10329-1i77ti5.rb 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.

  Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/opt/chef/embedded/bin/ruby
    --with-pg
    --without-pg
    --enable-windows-cross
    --disable-windows-cross
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --without-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib

  extconf failed, exit code 1

  Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/pg-0.18.1 for inspection.
  Results logged to /opt/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/pg-0.18.1/gem_make.out
  ---- End output of /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "0.18.1" ----
  Ran /opt/chef/embedded/bin/gem install pg -q --no-rdoc --no-ri -v "0.18.1" returned 1

  Cookbook Trace:
  ---------------
  /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:57:in `rescue in from_file'
  /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:23:in `from_file'
  /var/chef/cache/cookbooks/shipcloud_app/recipes/default.rb:112:in `from_file'

  Resource Declaration:
  ---------------------
  # In /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb

   57:     chef_gem "pg"
   58:   rescue Gem::Installer::ExtensionBuildError, Mixlib::ShellOut::ShellCommandFailed => e

  Compiled Resource:
  ------------------
  # Declared in /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:57:in `rescue in from_file'

  chef_gem("pg") do
    action :install
    retries 0
    retry_delay 2
    default_guard_interpreter :default
    package_name "pg"
    version "0.18.1"
    timeout 900
    gem_binary "/opt/chef/embedded/bin/gem"
    declared_type :chef_gem
    cookbook_name "postgresql"
    recipe_name "ruby"
  end

 [2015-02-24T14:30:25+00:00] WARN: Failed to properly build pg gem. Forcing properly linking and retrying (omnibus fix)
* execute[generate pg gem Makefile] action run
  - execute PATH=$PATH:/usr/pgsql-9.3/bin /opt/chef/embedded/bin/ruby extconf.rb
* execute[make pg gem lib] action run

  ================================================================================
  Error executing action `run` on resource 'execute[make pg gem lib]'
  ================================================================================

  Errno::ENOENT
  -------------
  No such file or directory - make

  Cookbook Trace:
  ---------------
  /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:101:in `rescue in rescue in from_file'
  /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:56:in `rescue in from_file'
  /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:23:in `from_file'
  /var/chef/cache/cookbooks/shipcloud_app/recipes/default.rb:112:in `from_file'

  Resource Declaration:
  ---------------------
  # In /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb

   96:     lib_maker = execute 'make pg gem lib' do
   97:       command 'make'
   98:       cwd ext_dir
   99:       action :nothing
  100:     end
  101:     lib_maker.run_action(:run)

  Compiled Resource:
  ------------------
  # Declared in /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:96:in `rescue in rescue in from_file'

  execute("make pg gem lib") do
    action [:nothing]
    retries 0
    retry_delay 2
    default_guard_interpreter :execute
    command "make"
    backup 5
    cwd "/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/pg-0.18.1/ext"
    returns 0
    declared_type :execute
    cookbook_name "postgresql"
    recipe_name "ruby"
  end


================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/shipcloud_app/recipes/default.rb
================================================================================

Errno::ENOENT
-------------
execute[make pg gem lib] (postgresql::ruby line 96) had an error: Errno::ENOENT: No such file or directory - make

Cookbook Trace:
---------------
  /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:101:in `rescue in rescue in from_file'
  /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:56:in `rescue in from_file'
  /var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:23:in `from_file'
  /var/chef/cache/cookbooks/shipcloud_app/recipes/default.rb:112:in `from_file'

Relevant File Content:
----------------------
/var/chef/cache/cookbooks/postgresql/recipes/ruby.rb:

 94:      lib_builder.run_action(:run)
 95:
 96:      lib_maker = execute 'make pg gem lib' do
 97:        command 'make'
 98:        cwd ext_dir
 99:        action :nothing
100:      end
101>>     lib_maker.run_action(:run)
102:
103:      lib_installer = execute 'install pg gem lib' do
104:        command 'make install'
105:        cwd ext_dir
106:        action :nothing
107:      end
108:      lib_installer.run_action(:run)
109:
110:      spec_installer = execute 'install pg spec' do


Running handlers:
 [2015-02-24T14:30:30+00:00] ERROR: Running exception handlers
Running handlers complete
 [2015-02-24T14:30:30+00:00] ERROR: Exception handlers complete
 [2015-02-24T14:30:30+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out

/opt/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/pg-0.18.1/mkmf.log: http://pastebin.com/dQMgyHGP