edelight / chef-mongodb

MongoDB Chef cookbook
https://community.opscode.com/cookbooks/mongodb
Apache License 2.0
363 stars 3 forks source link

Locking mongo gem to specific version #335

Closed cjhubert closed 10 years ago

cjhubert commented 10 years ago

It seems like after an update to the mongo ruby gem, unable to run the recipe successfully on Ubuntu 12.04. Just am getting:

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

Gem::Installer::ExtensionBuildError       
-----------------------------------       
ERROR: Failed to build gem native extension.       

        /opt/chef/embedded/bin/ruby extconf.rb       
checking for sasl/sasl.h... no       
checking for sasl_version() in -lsasl2... no       
creating Makefile       

make       
compiling csasl.c       
csasl.c:16:23: fatal error: sasl/sasl.h: No such file or directory       
compilation terminated.       
make: *** [csasl.o] Error 1       

Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mongo-1.11.0 for inspection.       
Results logged to /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mongo-1.11.0/ext/csasl/gem_make.out

This change just locks it to a specific version that works, though ideally we'd want to eventually figure out why the change broke the cookbook.

cjhubert commented 10 years ago

It seems like the same solution that applied to the PHP mongo driver applies here, if I run sudo apt-get install libsasl2-dev it fixes it. Not sure how we solve this in the cookbook, though.

agperson commented 10 years ago

Because chef_gem is run in the compile phase, that dependency must also be satisfied in the compile phase. For the moment I'm using this hacky approach:

package 'libsasl2-dev' do
  action :nothing
end.run_action(:install)
cjhubert commented 10 years ago

Interesting, with my changes I was able to kitchen converge the ubuntu 12.04 boxes. Are you running on a different platform? What error were you getting?

pburkholder commented 10 years ago

To provide context to@agperson's comment:

--- a/recipes/mongo_gem.rb
+++ b/recipes/mongo_gem.rb
@@ -6,6 +6,10 @@ gcc = package 'gcc' do
 end
 gcc.run_action(:install)

+package 'libsasl2-dev' do
+  action :nothing
+end.run_action(:install)
+
 node['mongodb']['ruby_gems'].each do |gem, version|
cjhubert commented 10 years ago

Right, I understand now that he means that instead of my change. I'm fine with that change instead, just not sure how to go about actually fixing this. Maybe logging a bug in mongo's jira to at least let them know about it?

pburkholder commented 10 years ago

@ceejh: Looks like csasl is now core to the ruby driver, so we'll probably just have to live with this. See https://github.com/mongodb/mongo-ruby-driver/pull/459

Here's the diff for RHEL also:

--- a/recipes/mongo_gem.rb
+++ b/recipes/mongo_gem.rb
@@ -6,6 +6,16 @@ gcc = package 'gcc' do
 end
 gcc.run_action(:install)

+if platform_family?('rhel')
+  sasldev_pkg = 'cyrus-sasl-devel'
+else
+  sasldev_pkg = 'libsasl2-dev'
+}
+
+package sasldev_pkg do
+  action :nothing
+end.run_action(:install)
+
 node['mongodb']['ruby_gems'].each do |gem, version|
   chef_gem gem do
     version version

You want to use this in the PR, or shall I submit one? (you get the credit here for raising this - thanks!)

cjhubert commented 10 years ago

Feel free to submit it as a separate PR and I'll close this one, thanks for doing the research into it.

pburkholder commented 10 years ago

Submitted PR #355. Cheers, Peter