1

I just got this issue during installing Redmine on Digital Ocean cloud server (I'm using Centos 7). After I bundle install, I got this error message,

An error occurred while installing mysql2 (0.3.16), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.16'` succeeds before bundling.

Then I try to install mysql2 using this command

gem install mysql2

An error message pop out,

Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby -r ./siteconf20140913-16462-tdplhf-0.rb extconf.rb
checking for ruby/thread.h... no
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... no
checking for rb_hash_dup()... no
checking for rb_intern3()... no
-----
Using mysql_config at /usr/bin/mysql_config
-----
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing.  please check your installation of mysql and try again.
-----
*** 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
    --without-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=/usr/bin/ruby
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysql-config
    --without-mysql-config

extconf failed, exit code 1

Gem files will remain installed in /usr/lib64/ruby/gems/1.8/gems/mysql2-0.3.16 for inspection.
Results logged to /usr/lib64/ruby/gems/1.8/extensions/x86_64-linux/1.8/mysql2-0.3.16/gem_make.out

I follow this tutorial how to setup Ruby on Rails: https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-on-centos-6

And Redmine: http://www.redmine.org/projects/redmine/wiki/How_to_Install_Redmine_on_CentOS_(Detailed)

halfer
  • 19,824
  • 17
  • 99
  • 186
Nurdin
  • 23,382
  • 43
  • 130
  • 308
  • possible duplicate of [Errors Installing mysql2 gem via the Bundler](http://stackoverflow.com/questions/3754662/errors-installing-mysql2-gem-via-the-bundler) – Holger Just Sep 15 '14 at 09:11

3 Answers3

3

Try installing mysql-devel package and try again

yum install mysql-devel
The Lazy Log
  • 3,564
  • 2
  • 20
  • 27
1

Anyone having this problem, here is what I did

First install latest version of mysql is installed to your machine by running

brew upgrade mysql

and then run

sudo gem install mysql2

bubb
  • 599
  • 4
  • 3
1

On my mac I also had this problem.

brew install mysql

this command installed mysql and after that I can repeat command:

bundle install

that it!

mmike
  • 706
  • 1
  • 8
  • 22