我使用下面的命令来安装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我无法理解是什么导致了这种情况,因为提到的所有目录都已经存在。
下面是我的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`我总是收到“系统找不到指定的路径。”这可能是造成这种情况的原因吗?我尝试在安装时包含mysql dir和mysql config,但没有成功。
下面是我在使用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发布于 2015-01-27 08:12:04
做对了
您需要做的就是重新安装sql,并确保安装文件夹名称的位置没有空格,然后下载较新的连接器mysql- connector -c-6.1.5-winx64.msi,升级mysql完整版附带的连接器。
之后,将msql中的libmysql.dll文件复制到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"‘
这就是我是如何做对的。
发布于 2014-03-12 15:59:58
win7 X64bit还是32位?
你安装过DevKit吗?
或者安装mysql-connector--(下载存档版本)并使用
gem install mysql2 --platform=ruby -- '--with-mysql-dir="D:\mysql-connector"'https://stackoverflow.com/questions/22344402
复制相似问题