chef-mariadb icon indicating copy to clipboard operation
chef-mariadb copied to clipboard

Mysql chef gem compilation error

Open jenssegers opened this issue 11 years ago • 15 comments

When running mariadb::ruby I get this error:

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


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

        /opt/chef/embedded/bin/ruby extconf.rb
checking for mysql_ssl_set()... *** 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-mysql-config
    --without-mysql-config
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
    from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
    from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
    from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:894:in `block in have_func'
    from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:893:in `have_func'
    from extconf.rb:45:in `<main>'


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



Cookbook Trace:
---------------
/root/chef-solo/cookbooks-2/mariadb/recipes/ruby.rb:34:in `from_file'


Resource Declaration:
---------------------
# In /root/chef-solo/cookbooks-2/mariadb/recipes/ruby.rb

 34: chef_gem 'mysql'



Compiled Resource:
------------------
# Declared in /root/chef-solo/cookbooks-2/mariadb/recipes/ruby.rb:34:in `from_file'

chef_gem("mysql") do
  provider Chef::Provider::Package::Rubygems
  action :install
  retries 0
  retry_delay 2
  guard_interpreter :default
  package_name "mysql"
  version "2.9.1"
  cookbook_name :mariadb
  recipe_name "ruby"
end

Is there a way to fix this? Maybe I'm missing some dependencies?

jenssegers avatar Jun 30 '14 10:06 jenssegers

I haven't spent much time with the ruby recipe recently. I'll see if I can take a look at it later today and piece together what might be happening.

joerocklin avatar Jun 30 '14 11:06 joerocklin

I have been struggling with this issue for a whole day, still can't get it to work :s

jenssegers avatar Jun 30 '14 21:06 jenssegers

I had an issue for myself and used another way to go around (just copied some lines from the opscode mysql cookbook ^^). Perhaps my mariadb::ruby can help you, too? You could try my fork. If it helps, I would open a pull request for Joe.

bpieck avatar Jul 01 '14 14:07 bpieck

@bpieck I did a similar pull request: https://github.com/joerocklin/chef-mariadb/pull/14

But it still did not solve the compilation issue.

jenssegers avatar Jul 01 '14 14:07 jenssegers

The mysql2 gem has no problems by the way.

jenssegers avatar Jul 01 '14 14:07 jenssegers

Wouldn't it work for you, to fork the database cookbook and just move to mysql2? It doesn't make sense to use both, I think.

bpieck avatar Jul 01 '14 14:07 bpieck

I'm not really a Ruby developer, so I don't know what the main differences are between those 2 :)

jenssegers avatar Jul 01 '14 14:07 jenssegers

short anwer: it's faster, a bit longer answer: http://stackoverflow.com/questions/5411551/what-the-difference-between-mysql-and-mysql2-gem

bpieck avatar Jul 01 '14 14:07 bpieck

It's interface/methods are not really 100% compatible with the mysql gem. I had to change some stuff but it seems to be working now!

jenssegers avatar Jul 01 '14 15:07 jenssegers

unless the mysql gem is required for the installation / management of mysql / mariadb, then it shouldn't be included. if it is required for that reason, then mysql2 should be used in place of the older mysql gem.

neurogenesis avatar Jul 01 '14 16:07 neurogenesis

The mysql2 gem is only usable with changes to the database cookbook. So, it would be better if mysql would work :)

jenssegers avatar Jul 01 '14 19:07 jenssegers

I'm not really sure how to proceed with this one. The opscode database cookbook has moved to using a stand-alone cookbook for the express purpose of installing the mysql gem: https://github.com/opscode-cookbooks/mysql-chef_gem. This would seem to remove the need for the mariadb::ruby recipe. Would there be objections to removing the recipe?

joerocklin avatar Jul 01 '14 21:07 joerocklin

Yes, objections. This mysql-chef_gem won't work, since it includes mysql::client - what does not work with mariadb installation of your cookbook. Look into Jenssegers pull request or into my fork. We have both adapted these changes into your cookbook (only I did not add the mysql2 chef_gem since database cookbook uses the mysql chef_gem and mysql2 chef_gem never would come into action, unless you use the database-cookbook change to mysql2 jens has made himself).

bpieck avatar Jul 01 '14 21:07 bpieck

But I think you don't have to do anything inside this issue. Jens worked around his issue, that must have to do something with his environment. I cannot imagine why he can install mysql2 gem but not mysql gem (both need mariadb headers - so he must have been able to install them, although I thought his error messages imply they would be not existent). I think the discussion about the change to mysql-chef_gem belongs into jens pull request.

bpieck avatar Jul 01 '14 21:07 bpieck

@bpieck Objection heard! I'll see if I can get some time to review the PR and get it merged in.

joerocklin avatar Jul 01 '14 21:07 joerocklin