0

I am deploying my Rails application using Chef. While

gem install mysql

am getting hte following error,

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:intry_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:intry_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:inblock 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:inopen' 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:inopen' 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:inchecking_for' from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:893:in have_func' from extconf.rb:45:in'

Gem files will remain installed in /var/www/project-name/releases/daf93f4783a7238e5a8198c1fd50e4e1de93f654/vendor/bundle/ruby/1.9.1/gems/mysql-2.9.1 for inspection. Results logged to /var/www/project-name/releases/daf93f4783a7238e5a8198c1fd50e4e1de93f654/vendor/bundle/ruby/1.9.1/gems/mysql-2.9.1/ext/mysql_api/gem_make.out An error occured while installing mysql (2.9.1), and Bundler cannot continue. Make sure that gem install mysql -v '2.9.1' succeeds before bundling.

I am using RHEL 6. I also have a separate cookbook for mysql installation. I tried installing Mysql manually using the yum command.

I tried

yum install mysql-devel and then run the gem install mysql

still not working. Can anyone help me out.

Thanks

rajkumarts
  • 399
  • 1
  • 7
  • 20
  • Maybe `yum install mysql mysql-server mysql-devel` ? – MrYoshiji Aug 21 '13 at 20:44
  • @MrYoshiji - i tried that and am getting the following error Protected multilib versions: mysql-libs-5.1.69-1.el6_4.i686 != mysql-libs-5.5.33-1.el6.remi.x86_64 Error: Protected multilib versions: mysql-5.1.69-1.el6_4.i686 != mysql-5.5.33-1.el6.remi.x86_64 You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest – rajkumarts Aug 21 '13 at 20:59
  • `yum install mysql2` ? Seen here: http://stackoverflow.com/questions/3933829/error-installing-mysql2-gem-failed-to-build-gem-native-extension?rq=1 – MrYoshiji Aug 21 '13 at 21:01
  • thats not working either – rajkumarts Aug 21 '13 at 21:14
  • Oh I meant `gem install mysql2` and not with yum, also check this: http://stackoverflow.com/questions/3608287/error-installing-mysql2-failed-to-build-gem-native-extension – MrYoshiji Aug 21 '13 at 21:15

2 Answers2

2

It sounds like you don't have a compiler. On a debian/ubuntu system, you can get everything you need to compile and build packages with:

sudo apt-get install build-essential

On Fedora/Red Hat I think it should be:

sudo yum groupinstall "Development Tools"
Aaron Blenkush
  • 3,034
  • 2
  • 28
  • 54
aruanoc
  • 817
  • 1
  • 7
  • 9
  • I tried the sudo yum command and got the following error This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Setting up Group Process epel/group_gz | 237 kB 00:00 No packages in any requested group available to install or update – rajkumarts Aug 21 '13 at 21:38
  • Did you try to register? https://access.redhat.com/site/documentation/en-US/Red_Hat_Subscription_Management/1.0/html/Subscription_Management_Guide/registering-machine-ui.html – aruanoc Aug 22 '13 at 14:59
  • i got the Development tools working .. still the mysql gem throws the same error. – rajkumarts Aug 22 '13 at 17:43
1

Add the build-essentials cookbook to your runlist and configure it's "compiletime" attribute.

The following answer reports the same problem building the postgres gem

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185