Cannot install mysql2 0.3.14 gem
Asked Answered
H

1

5

I see that others have had a similar problem but none of the solutions have worked for me. The 0.3.14 gem is present in with the other gem files. I've done everything exactly as indicated here: https://github.com/brianmario/mysql2. Still I get the following. I don't know why the installer is indicating it can't find the include directory, as I've checked and it's present. The thread.h file exists, but not in the ruby directory. Rather it is here: C:\RailsInstaller\DevKit\lib\perl5\5.8\msys\CORE\

I'm running Windows 7 and trying to build my rails project in Aptana 3. My Ruby is 1.9.3.

$ gem install mysql2 -v 0.3.14 -- --with-mysql-dir=C:\MySQL-Connector-C-6.1
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:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb --with-mysql-dir=C:MySQL-Connector-C-6.1
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
-----
Cannot find include dir at C:MySQL-Connector-C-6.1/include
-----
*** 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=c:/RailsInstaller/Ruby1.9.3/bin/ruby
        --with-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib


Gem files will remain installed in c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.14 for inspection.
Results logged to c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.14/ext/mysql2/gem_make.out

Also tried this:

$ gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\MySQL-Connector-C-6.1\lib" --with-mysql-include="C:\MySQL-Connector-C-6.1
\include" --with-mysql-dir="C:\MySQL-Connector-C-6.1"'
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:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb --with-mysql-lib="C:\MySQL-Connector-C-6.1\lib" --with-mysql-include="C:\MyS
QL-Connector-C-6.1\include" --with-mysql-dir="C:\MySQL-Connector-C-6.1"
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
-----
Cannot find include dir at C:\MySQL-Connector-C-6.1\include;C:\MySQL-Connector-C-6.1\include;C:\MySQL-Connector-C-6.1/include
-----
*** 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.


Gem files will remain installed in c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.14 for inspection.
Results logged to c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.14/ext/mysql2/gem_make.out

And the alternative suggested configuration:

$ gem install mysql2 -v 0.3.14 -- '--with-mysql-config="C:\wamp\bin\mysql\mysql5.5.24\bin"'
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:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb --with-mysql-config="C:\wamp\bin\mysql\mysql5.5.24\bin"
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
-----
Using mysql_config at C:\wamp\bin\mysql\mysql5.5.24\bin
-----
*** 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.


extconf.rb:55:in ``': Permission denied - C:\wamp\bin\mysql\mysql5.5.24\bin --version (Errno::EACCES)
        from extconf.rb:55:in `<main>'


Gem files will remain installed in c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.14 for inspection.
Results logged to c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.14/ext/mysql2/gem_make.out

For the sake of clarity, I have removed the redundant configuration options here. Note that this attempt generated a permission denied error.

Hairpin answered 29/11, 2013 at 5:14 Comment(4)
github.com/brianmario/mysql2/issues/359#issuecomment-16000721Leucopoiesis
#6259193Varia
I already saw that conversation and tried what was suggested. Same problem.Hairpin
fatfrog -- already read that thread and tried that. No luck.Hairpin
H
10

I found the problem! Here's the issue. Instructions said to copy the libmysql.dll file to the ruby home directory. The file that needs to be copied is NOT the .dll -- it's the libmysql.lib file (or both). I copied that over and it compiled fine. Yay!

$ gem install mysql2 -v 0.3.14 -- '--with-mysql-dir="C:\MySQL-Connector-C-6.1"'
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.14
1 gem installed
Installing ri documentation for mysql2-0.3.14...
Installing RDoc documentation for mysql2-0.3.14...
Hairpin answered 29/11, 2013 at 14:10 Comment(1)
Just have to login to say thanks! "copying the libmysql.dll file to the ruby home directory" is really the key point, though it seems to me that the .lib file is not necessary. Windows users also need to pay attention to the architecture of the mysql connector (ie. x86(win32) or x64(win64) ), which is also crucial to the build. My environment is: Windows7, ruby 1.9.3, rails 3.2.15, mysql-connector-c-6.0.2-win32 for the gem mysql2-0.3.14. Sadly the win64 version of the connector doesn't work for meShelter

© 2022 - 2024 — McMap. All rights reserved.