Tags

, , ,

Below is a sample bundle install error:

$ bundle install

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.
        c:/Ruby193-p392/bin/ruby.exe extconf.rb
checking for ruby/thread.h... no
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file fo
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=c:/Ruby193-p392/bin/ruby
...
...
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.

Solution A. If you’re using xampp in windows, you can solve the issue by using this command:

$ gem uninstall mysql2   # uninstall the mysql2
Select gem to uninstall:
 1. mysql2-0.3.19-x64-mingw32
 2. mysql2-0.4.5-x64-mingw32
 3. All versions
> 3
$ gem install mysql2 -- '--with-mysql-lib="C:\xampp\mysql\lib" --withmysql-include="C:\xampp\mysql\include"'
Fetching: mysql2-0.3.19-x86-mingw32.gem (100%)
===================================================================
  You've installed the binary version of mysql2.
  It was built using MySQL Connector/C version 6.1.6.
  It's recommended to use the exact same version to avoid potential issues.
  At the time of building this gem, the necessary DLL files were retrieved from:
  http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-6.1.6-win32.zip
  This gem *includes* vendor/libmysql.dll with redistribution notice in vendor/README.

Successfully installed mysql2-0.3.19-x86-mingw32
1 gem installed

Next, extract the downloaded file(mysql-connector-c-6.1.6-win32.zip) 
into your temporary folder and copy/paste the libmysql.dll 
from mysql-connector-c-6.1.6-win32/lib folder 
to C:\Ruby{release-version}\bin folder
...

Solution B. If you’re using Mysql Installer(e.g. mysql-installer-web-community-5.7.17.0.msi)

$ gem uninstall mysql2 
Select gem to uninstall:
 1. mysql2-0.3.19-x64-mingw32
 2. mysql2-0.4.5-x64-mingw32
 3. All versions
> 3
Successfully uninstalled mysql2-0.3.19-x64-mingw32
Successfully uninstalled mysql2-0.4.5-x64-mingw32
$ gem install mysql2 -- '--with-mysql-lib="C:\Program Files\MySQL\MySQL Server 5.7\lib"
Fetching: mysql2-0.4.5-x64-mingw32.gem (100%)
===================================================================
  You've installed the binary version of mysql2.
  It was built using MySQL Connector/C version 6.1.6.
  It's recommended to use the exact same version to avoid potential issues.
  At the time of building this gem, the necessary DLL files were retrieved from:
  http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-6.1.6-win32.zip
  This gem *includes* vendor/libmysql.dll with redistribution notice in vendor/README.
===================================================================
Successfully installed mysql2-0.4.5-x64-mingw32
1 gem installed

Next, extract the downloaded file(mysql-connector-c-6.1.6-win32.zip) 
into your temporary folder and copy/paste the libmysql.dll 
from mysql-connector-c-6.1.6-win32/lib folder 
to C:\Ruby{release-version}\bin folder
...

References:
https://sudogem.wordpress.com/2013/01/31/ruby-on-rails-problem-with-mysql-and-rails-in-windows-7/

Advertisements