在Windows 7上安装mysql2 gem时出错

时间:2014-03-12 07:12:52

标签: ruby gem watir-webdriver mysql2

我使用下面的命令来安装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"'

但低于错误

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

我无法理解导致这种情况的原因,因为所有提到的目录都已存在。

下面是我的宝石环境

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`

我总是得到“系统无法找到指定的路径。”这可能是这个原因。我已经尝试在安装时包含mysql dir和mysql配置,但没有成功。

以下是我使用mysql连接器获取的错误:

    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

2 个答案:

答案 0 :(得分:1)

做对了

您需要做的就是重新安装sql并确保安装文件夹名称的位置没有空格,在下载后更新的连接器mysql-connector-c-6.1.5-winx64.msi升级一个随mysql完整版一起提供的。

之后将文件libmysql.dll从msql复制到ruby文件夹中我假设你已经知道这些图片是否应该帮助你https://medium.com/@frontlineutils/installing-the-mysql2-rubyonrails-gem-on-windows-7-8-a028f44d87f3

再次运行gem安装,例如gem install mysql2 - ' - with-mysql-include =“C:\ Files \ MySQL56 \ include”--with-mysql-lib =“C:\ Files \ MySQL56 \ lib “'

这就是我如何做对的。

答案 1 :(得分:0)

win7 X64bit还是32bit?

你有没有安装DevKit

或安装mysql-connector - (下载档案版)并使用

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

more mysql2 issues info