1

I'm trying to install the mysql2 gem on Windows 8 (Ruby 1.9.3 and Rails 4.0.1). I've installed the Devkit and it's working properly, and I'm entering the following:

gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\mysql-connector\lib" --with-mysql-include="C:\mysql-connector\include" --with-mysql-dir="C:\mysql-conector"'

I've done this before and it's worked, but for some reason this time it's throwing this bizarre message:

Cannot find include dir at C:\mysql-connector\include;C:\mysql-connector\include;C:\mysql-connector/include;

This is of course in addition to the whole "Could not create makefile for some reason..." message. I'm using the mysql connector that I found through a different post here--Ruby MYSQL2 gem installation on windows 7

Does anyone know how I can fix this? I really need this gem...

Community
  • 1
  • 1
Joeman29
  • 712
  • 5
  • 14

2 Answers2

6

I figured this out... All I had to do was:

gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\mysql-connector\"'

Strange though--last time it worked with the code above... Go figure...

Joeman29
  • 712
  • 5
  • 14
  • 1
    The point is to use the standalone mysql-connector-c.zip from http://dev.mysql.com/downloads/connector/c/ for the current platform (of Ruby), e.g. "Windows (x86, 32-bit), ZIP Archive" for 32-bit Ruby even on 64-bit Windows. Which is probably the reason why the one shipped with MySQL installer doesn't work. – ryenus Feb 24 '14 at 03:39
  • Also, add the version if a dependency requires it. The latest version the above gem install gets still caused me grief, so had to add "-v '0.3.17'" to get the one I needed. – rtfminc May 11 '15 at 10:07
0

I just ran into the exact same issue trying to install mysql2 0.3.14 on Window 64bit, Rails 3.2.15 and Ruby 2.0.0p247. I used a command very simliar to what user2986379 posted and it worked; literally 5 minutes later when I had to rerun the command to fix another issue it stopped working. I was even copying the command from notepad each time so there wasn't a typo. Odd.

Anyway, user2986379's solution of adding quotes to the paths helped me get past the issue, but I was still getting some errors. I ended up modifying the command by removing the single quotes. In case anyone needs it, here's the command I ran:

gem install mysql2 --platform=ruby -- --with-mysql-dir="C:\mysql-connector"

Lastly, just for completeness, I had to use the version of connector c located here. You can read more about why this is necessary at the bottom of https://github.com/brianmario/mysql2/issues/372. It will install fine, but without the special connector_c you might get a segmentation fault when you go to actually use the gem. (Don't forget to grab the libmysql.dll out of that special connector c zip file as well and place it in your ruby bin directory.)

WebDev
  • 1,097
  • 8
  • 6