When running ‘bundle install’ or ‘gem install mysql2’, I got following error:
>gem install mysql2
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
To solve this issue and to successfully install mysql2 gem, I took following steps:
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 linkhttps://github.com/oneclick/rubyinstaller/wiki/Development-Kit
3. Extracted the downloaded DevKit.
4. cd <DEVKIT_INSTALL_DIR>
5. run ruby dk.rb init.
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.
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.
And, congrats, you are done with installation of Mysql2 gem on Ruby 1.9.2 and Rails 3.0.8 on Windows.
gem install mysql2 -v 0.2.6
has been working flawlessly for me.