When running 'bundle install' or 'gem install mysql2', I got following error:
>gem install mysql2To solve this issue and to successfully install mysql2 gem, I took following steps:
ERROR: Error installing mysql2:
The 'mysql2' native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
1. Download Development Kit "http://github.com/downloads/oneclick/rubyinstaller/DevKit-tdm-32-4.5.1-20101214-1400-sfx.exe" from http://rubyinstaller.org/downloads/
2. Followed the instructions given on link https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
3. Extracted the downloaded DevKit.
4. cd <DEVKIT_INSTALL_DIR>
5. run ruby dk.rb init.
C:\Users\ritesh\Downloads\DevKit-tdm-32-4.5.1-20101214-1400-sfx>ruby dk.rb init
[INFO] found RubyInstaller v1.9.2 at C:/Ruby192
[INFO] found RubyInstaller v1.8.7 at C:/Ruby187
Initialization complete! Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit. 6. edit the generated config.yml file as per your system available Rubies version if required
7. [optional] ruby dk.rb review to verify the changes you made to it are correct.
8. finally, ruby dk.rb install to DevKit enhance your installed Rubies.
C:\Users\ritesh\Downloads\DevKit-tdm-32-4.5.1-20101214-1400-sfx>ruby dk.rb install
[INFO] Updating convenience notice gem override for 'C:/Ruby192'
[INFO] Installing 'C:/Ruby192/lib/ruby/site_ruby/devkit.rb'
[INFO] Skipping existing gem override for 'C:/Ruby187'
[WARN] Skipping existing DevKit helper library for 'C:/Ruby187'
9. You have successfully installed the DevKit, and now comes the step to install mysql2 gem, most important one for which we took so many steps. Make sure you are using Ruby 1.9.2 version.
10. Run gem install myql2 with parameters that I have passed, path can differ for you so make changes accordingly.
>gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.1\lib\opt" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.1\include"'
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed mysql2-0.2.7
1 gem installed
Installing ri documentation for mysql2-0.2.7...
Enclosing class/module 'mMysql2' for class Client not known
Installing RDoc documentation for mysql2-0.2.7...
Enclosing class/module 'mMysql2' for class Client not known
And, congrats, you are done with installation of Mysql2 gem on Ruby 1.9.2 and Rails 3.0.5 on Windows.