0

I am using below command to install mysql2 gem:

gem install mysql2 -- '--with-mysql-include="C:\Program Files\MySQL\MySQL Server 5.6\include" --with-mysql-lib="C:\Program Files\MySQL\MySQL Server 5.6\lib"'

but getting below error

C:\Ruby200\bin>gem install mysql2 -- '--with-mysql-include="C:\Program Files\MyS
QL\MySQL Server 5.6\include" --with-mysql-lib="C:\Program Files\MySQL\MySQL Serv
er 5.6\lib"'
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-include="C:\Program Files\MySQL\M
ySQL Server 5.6\include" --with-mysql-lib="C:\Program Files\MySQL\MySQL Server 5
.6\lib"'
This could take a while...
The system cannot find the path specified.
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

    C:/Ruby200/bin/ruby.exe extconf.rb --with-mysql-include="C:\Program Files\My
SQL\MySQL Server 5.6\include" --with-mysql-lib="C:\Program Files\MySQL\MySQL Ser
ver 5.6\lib"
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
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 --with-mysql-dir=C:\Program Files\MySQL\MySQL Server 5.6
-----
checking for main() in -llibmysql... yes
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.
3.15 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/extensions/x86-mingw32/2.0.0/my
sql2-0.3.15/gem_make.out

i am unable to understand what is causing this as all the directories mentioned are already present.

below is my gem env

C:\Ruby200\bin>gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.2
  - RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [i386-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby200/lib/ruby/gems/2.0.0
  - RUBY EXECUTABLE: C:/Ruby200/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby200/bin
  - SPEC CACHE DIRECTORY: D:/Users/zzuj001/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - C:/Ruby200/lib/ruby/gems/2.0.0
     - D:/Users/zzuj001/.gem/ruby/2.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["http://rubygems.org/", "http://gems.github.com"]
  - REMOTE SOURCES:
     - http://rubygems.org/
     - http://gems.github.com
  - SHELL PATH:
     - C:\Ruby200\bin
     - C:\Ruby200\bin
     - C:\Windows\system32
     - C:\Windows
     - C:\Windows\System32\Wbem
     - C:\Windows\System32\WindowsPowerShell\v1.0\
     - c:\Program Files\Microsoft SQL Server\100\Tools\Binn\
     - c:\Program Files\Microsoft SQL Server\100\DTS\Binn\
     - c:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\

     - C:\PROGRA~1\IBM\SQLLIB\BIN
     - C:\PROGRA~1\IBM\SQLLIB\FUNCTION
     - C:\PROGRA~1\IBM\SQLLIB\SAMPLES\REPL
     - C:\Program Files\HP\Virtual User Generator\strawberry-perl\perl\bin
     - C:\Program Files\HP\Unified Functional Testing\bin
     - C:\Program Files\MySQL\MySQL Utilities 1.3.6\`enter code here`

I am always getting "The system cannot find the path specified.". Could this be the reason of this. I've tried including mysql dir and mysql config while installing but no success.

Below is the error that i am getting with mysql connector:

    D:\Users\zzuj001>gem install mysql2 --platform=ruby -- '--with-mysql-dir="c:\mys
qlconnector"'
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-dir="c:\mysqlconnector"'
This could take a while...
The system cannot find the path specified.
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    C:/Ruby200/bin/ruby.exe extconf.rb --with-mysql-dir="c:\mysqlconnector"
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
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 --with-mysql-dir=c:\mysqlconnector
-----
checking for main() in -llibmysql... yes
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Setting rpath to /lib
-----
creating Makefile

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.
3.15 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/extensions/x86-mingw32/2.0.0/my
sql2-0.3.15/gem_make.out
yudi2312
  • 323
  • 1
  • 4
  • 21
  • The question is answered here http://stackoverflow.com/questions/5367563/unable-to-install-mysql2-gem-on-windows-7 – Mani Aug 17 '15 at 06:33

2 Answers2

1

got it right

all you need to do is to re install sql and make sure that where you are installing the folder names do not have spaces, after that download a newer connector mysql-connector-c-6.1.5-winx64.msi upgrade the one that came with the mysql complete version.

after that copy the file libmysql.dll from msql into ruby folder which I assume you already know if not this pictures should help you https://medium.com/@frontlineutils/installing-the-mysql2-rubyonrails-gem-on-windows-7-8-a028f44d87f3

Run the gem installation again e.g gem install mysql2 -- '--with-mysql-include="C:\Files\MySQL56\include" --with-mysql-lib="C:\Files\MySQL56\lib"'

thats exactly how i got it right.

0

win7 X64bit or 32bit?

did you ever install DevKit?

or install a mysql-connector--(download the Archive version) and use

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

more mysql2 issues info

Leo Silence
  • 1,192
  • 11
  • 22
  • make sure your DevKit and ruby is 32bit version. – Leo Silence Mar 12 '14 at 08:10
  • i tried with mysql-connector that came with MYSQL, that is also throwing an error. – yudi2312 Mar 12 '14 at 08:14
  • @yudi2312 i think i can fix your"The system cannot find the path specified." problem. "C:\Program Files\MySQL\MySQL Server 5 .6\lib" "Program File"have a space will show that error. – Leo Silence Mar 12 '14 at 08:22
  • than how to avoid this thing. – yudi2312 Mar 12 '14 at 08:53
  • two ways: 1.reinstall mysql change the path. 2. use mysql-connector – Leo Silence Mar 12 '14 at 10:00
  • added in description.. and i think that the "The system cannot find the path specified" error is because of GEM PATH issue... one of them doesn't exist. – yudi2312 Mar 13 '14 at 08:01
  • I just had the same problem trying to create my first Rails project - during the setup I just ran "gem install mysql2" (no parameters), so it wasn't enough... I copied the entire MySQL Connector directory into a new "D:\MySQLConnector" directory (without spaces) and ran the "gem" command as stated above. It worked! – Bizarro Jun 03 '14 at 12:45