我在安装Windows 8.1机器时遇到了一些问题,需要安装mysql2 gem。我跟着这个帖子的说明:在Windows上安装MySQL2 Gem
安装mysql2
宝石,和我没有得到任何错误消息。
我跟着此与
bundle install
命令,确认以下的宝石被安装(使用束上显示),证实了我已经安装了以下宝石:
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>'
任何想法?
解决方法:
答案是从计算器两个答案,加修饰的组合。该计算器引用:
Ruby MYSQL2 gem installation on windows 7 ...mysql2/mysql2.so: [BUG] Segmentation fault ruby 2.0.0p247
底线:让mysql2在64位环境中使用Ruby 2个工作在Windows 8.1中,你需要做到以下几点:
清理:你在这里的原因是你可能在尝试 来安装这个gem,但它失败了,所以你有一些清理到 做:宝石卸载mysql2
下载红宝石2.0 64位的Windows:
http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.0.0-p353-x64.exe?direct
运行安装程序。请注意它安装的目录,并确保它位于用户路径中。去
Control Panel > System and Security > System - Advanced System Settings > Environment Variables
- 下载红宝石2 64位的开发工具包:
运行安装程序并记下安装目录的位置。说明指出,一旦完成安装,您需要运行devkitvars.bat文件来设置环境变量。这不适用于Windows 8.1。您需要重复说明以设置上面#2中描述的本地路径,为本地用户设置路径环境变量以添加ruby开发工具箱bin目录以及ruby dev工具包mingw bin目录。例如,如果开发套件安装到c:\ ruby2devkit,并安装ruby2到C:\ Ruby200-x64的目录,那么你的编辑你的路径语句看起来像这样:
C:\Ruby200-x64\bin;C:\ruby2-devkit\bin;c:\ruby2-devkit\mingw\bin
接下来你需要安装mysql连接器。请勿下载并运行自行安装程序。相反,请下载zip文件并将其解压缩。注意:您解压它(这个职位的目的,目录,让我们假设你把它解压到c:\ mysql的连接器:
包含在MySQL连接64位的libmysql.lib不与mingw64-gcc编译器兼容,你需要生成mingw64兼容libmysql.lib文件。
下载你娘家的工具d
https://structure-svm-map.googlecode.com/files/svm-map-win.zip
此文件解压到本地目录,让我们假设您解压缩它到c:\ SVM-地图
编辑PATH环境路径,如前所述,到现在看像这样:
C:\Ruby200-x64\bin;C:\ruby2-devkit\bin;c:\ruby2-devkit\mingw\bin;c:\svm-map;C:\svm-map\python-mingw-lib
生成新的MySQL库:
(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
安装如下宝石(注意使用正斜线而非反斜线,如果你用反斜杠它会失败):
创业板安装mysql2 --platform =红宝石 - “--with-mysql- DIR = “C:/ MySQL的连接器/””
做出红宝石安装目录下的bin目录确保路径是在本地用户的PATH环境变量(这也是确定的,如果它在系统PATH环境变量)
http://cdn.rubyinstaller.org/archives/devkits/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe
希望这会有所帮助,并希望有人会注意谁想要做的Ruby on Rails开发的一些Windows 8.1的用户。
尝试'创业板安装mysql2' – house9
的mysql2宝石已经是不显示的错误安装。请阅读我的问题。 – EastsideDeveloper
我使用64位Ruby 2.0运行64位Windows8.1。我可以确认这个解决方案有效。在#9之前,我必须再增加一组。我必须删除Bundle已经安装的mysql2 gem。当我尝试其他人的解决方案时,Bundle未能安装它们,但它仍然创建了gem目录并安装了一些文件。在步骤9之前删除它们使其工作! –