[英]Error installing mysql2 gem on windows 7
我正在使用以下命令安裝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 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
做對了
您需要做的就是重新安裝sql並確保要安裝的文件夾名稱中沒有空格,然后下載更新的連接器mysql-connector-c-6.1.5-winx64.msi升級隨附的連接器與mysql完整版。
之后,將文件mbsql.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”'
那就是我正確的方式。
WIN7 X64位或32位?
您是否安裝過DevKit ?
或安裝mysql-connector- (下載存檔版本)並使用
gem install mysql2 --platform=ruby -- '--with-mysql-dir="D:\mysql-connector"'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.