安装了mysql2
gem,并且没有收到任何错误消息。
接着我进行了下面的步骤。
bundle install
执行命令,并确认以下 gem 已安装(使用 bundle show),确认我已安装以下 gem:
Using devise (3.2.2)
Using mysql2 (0.3.14)
然后我尝试做:
rails generate devise:install
这就是我得到的内容:
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14/lib/mysql2.rb:8:in `require': 126: The specified module could not be found.
- C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14/lib/mysql2/mysql2.so (LoadError)
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14/lib/mysql2.rb:8:in `<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `block in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.1/lib/bundler.rb:131:in `require'
from C:/Users/Joseph/googledrive/projects/rails/test_new_devise/config/application.rb:7:in `<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:43:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:43:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
有什么想法吗?
解决方案:
答案是从stackoverflow的两个答案组合而来,加上一些修改。 stackoverflow参考资料如下:
在Windows 7上安装Ruby MYSQL2 gem ...mysql2/mysql2.so:[BUG]Segmentation fault ruby 2.0.0p247
底线是:要在Windows 8.1上使用64位环境和Ruby 2使mysql2正常工作,您需要执行以下操作:
清理:您来到这里的原因可能是尝试安装此gem并失败了,因此您需要进行一些清理:gem uninstall mysql2
下载Windows的Ruby 2.0 64位版本:
http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.0.0-p353-x64.exe?direct
Run the installer. Note the directory it installs to, and make sure it's in the User PATH. go to
Control Panel > System and Security > System - Advanced System Settings > Environment Variables
3. 下载 Ruby 2 64 位 Dev Kit:
http://cdn.rubyinstaller.org/archives/devkits/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe
Run the installer and note the location of the install directory. The instructions say that once you're done with the install, you need to run the devkitvars.bat file to set the environment variables. This DOES NOT work for Windows 8.1. You need to repeat the instructions to set the local path described in #2 above, to set the path environment variable for the local user to add the ruby dev kit bin directory, and the ruby dev kit mingw bin directory. For example, if the dev kit was installed to c:\ruby2devkit, and you installed ruby2 to the C:\Ruby200-x64 directory, then your edit your path statement to look like this:
C:\Ruby200-x64\bin;C:\ruby2-devkit\bin;c:\ruby2-devkit\mingw\bin
Next you need to install the mysql-connector. DO NOT download and run the self-installer. Instead, download the zip file and unpack it. Note the directory you unpacked it to (for the purposes of this post, let's assume you unpacked it to c:\mysql-connector:
The libmysql.lib included in the MySQL Connector 64 bit is not compatible with the mingw64-gcc compiler. You need to generate mingw64 compatible libmysql.lib file.
Download the tools you need
https://structure-svm-map.googlecode.com/files/svm-map-win.zip
Unzip this file to a local directory, let's assume that you unzipped it to c:\svm-map
Edit the PATH environment path, as described earlier, to now look like this:
C:\Ruby200-x64\bin;C:\ruby2-devkit\bin;c:\ruby2-devkit\mingw\bin;c:\svm-map;C:\svm-map\python-mingw-lib
Generate the new mysql libraries:
(make sure you're running as administrator) cd c:\mysql-connector\lib gendef.exe libmysql.dll dlltool -v --dllname libmysql.dll --def libmysql.def --output-lib libmysql.lib copy libmysql.dll C:\Ruby200-x64\bin copy libmysql.lib C:\Ruby200-x64\bin
Install the gem as follows (note the use of forward slashes instead of backslashes, it will fail if you use backslashes):
gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:/mysql-connector/"'
gem install mysql2
- house9gendef.exe
没有通知文件libmysql.def
未生成。 - Leonel Sanches da Silva