红宝石mysql2宝石安装错误 [英] ruby mysql2 gem install error

查看:100
本文介绍了红宝石mysql2宝石安装错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在windows机器上安装mysql2 gem时遇到问题,通常它工作正常,但现在我得到了无法构建原生扩展。我用google搜索了一下,但有一个很多linux修复。我知道使用ruby在windows上工作并不是最好的。回到问题,我用 gem install mysql2 - --with-mysql-dir = C:\wamp\bin\mysql\mysql5.6.12\bin --with-mysql -lib = C:\wamp\bin\mysql\mysql5.6.12\lib 安装mysql2,它适用于mysql,但rails需要mysql2。



谢谢。

解决方案

mysql2安装起来可能会很棘手。我们只是得到了一个开发框,使用Ruby 2.0.0p247,Windows 64bit和mysql 0.3.13。这里有一些建议:


  1. 确保您安装了最新的DevKit( http://rubyinstaller.org/downloads/ )。在页面的右栏中,它会告诉您您的特定版本的Ruby需要使用哪个版本的DevKit。我们发现将它安装到C:\DevKit最简单

  2. 现在尝试运行 gem install mysql2 .. >。你在你的问题中列出的命令。或者,对于32位安装,我们可以这样做:



 
subst X:C:\ Program Files(x86)\MySQL\MySQL Server 5.6
gem install mysql2 -v = 0.3.13 --platform = ruby​​ - --with-mysql-include = X:\include --with -mysql-lib = X:\lib
subst X:/ d

subst 命令将创建一个虚拟驱动器并帮助处理路径名称中的空格。
$ b


  1. 将C:\ Program Files(x86)\MySQL\MySQL Server 5.6\lib\libmysql.dll复制到你的Ruby bin目录。如果您使用的是32位系统,则应该关闭并运行。

64位用户在获取mysql2后可能会遇到另一个错误建立。上述步骤似乎可行,但是当他们实际上使用mysql2 gem来执行一些有用的操作时,比如运行 rake db:create 时,他们会遇到分段错误。有关此问题的更多信息和解决办法,请访问 https://github.com/brianmario/mysql2 / issues / 372 https://bugs.ruby-lang.org/issues/ 8591 https://groups.google.com/forum/# !topic / ruby​​installer / uTNffOt6Yqo

长话短说,需要使用兼容的mysql连接器c来代替MySQL服务器目录。有用的用户提供了正确的连接器c,并且可以在此处下载( https://www.copy.com/s/CHZ4eT4us6f1/mysql-connector-c-noinstall-6.0.2-winx64.zip )。提取该zip文件,然后将 gem install mysql2 ...命令指向相应的目录,然后64bit快乐将会出现。 (不要忘记从下载的连接器c文件夹中获取libmysql.dll,并将其放置在ruby bin目录中)。


I am having problems installing mysql2 gem on my windows machine, usually it worked, but now I get Failed to build native extension. I googled around, but there were a lot of linux fixes. I know its not the best thing to work on windows with ruby. Back to the problem, I used gem install mysql2 -- --with-mysql-dir=C:\wamp\bin\mysql\mysql5.6.12\bin --with-mysql-lib=C:\wamp\bin\mysql\mysql5.6.12\lib to install mysql2, it works with mysql, but rails requires mysql2.

Thank you.

解决方案

mysql2 can be tricky to install. We JUST got a dev box working with Ruby 2.0.0p247, Windows 64bit and mysql 0.3.13. Here are some suggestions:

  1. Make sure you have the latest DevKit installed (http://rubyinstaller.org/downloads/). On the right column of the page, it tells you which version of the DevKit you'll need for your particular version of Ruby. We've found it was easiest to install it to C:\DevKit

  2. Now try and run the gem install mysql2 ... command you listed in your question. Alternatively, for 32bit installs we do:

subst X: "C:\Program Files (x86)\MySQL\MySQL Server 5.6"
gem install mysql2 -v=0.3.13 --platform=ruby -- --with-mysql-include=X:\include --with-mysql-lib=X:\lib
subst X: /d

The subst command creates a virtual drive and helps with the spaces in the path name.

  1. Copy the C:\Program Files (x86)\MySQL\MySQL Server 5.6\lib\libmysql.dll to your Ruby bin directory. You should be off and running if you're working with 32bit.

64bit users however will likely run into another bug once they get mysql2 to build. The above steps will appear to work, but when they actually go to use the mysql2 gem to do something useful, like run rake db:create, they get a segmentation fault. More info and a fix for the issue can be found at https://github.com/brianmario/mysql2/issues/372, https://bugs.ruby-lang.org/issues/8591, https://groups.google.com/forum/#!topic/rubyinstaller/uTNffOt6Yqo

Long story short, a compatible mysql connector c needs to be used instead of the MySQL server directory. A helpful user provided the right connector c and it can be downloaded here (https://www.copy.com/s/CHZ4eT4us6f1/mysql-connector-c-noinstall-6.0.2-winx64.zip). Extract that zip file, and point your gem install mysql2 ... command to the appropriate directories and 64bit happiness will follow. (Don't forget to grab the libmysql.dll from the downloaded connector c folder and place it in your ruby bin directory).

这篇关于红宝石mysql2宝石安装错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆