在Windows 7上安装Ruby MYSQL2 gem安装 [英] Ruby MYSQL2 gem installation on windows 7

查看:97
本文介绍了在Windows 7上安装Ruby MYSQL2 gem安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Windows 7上安装mysql2 gem我从mysql网站下载连接器,并将libmysql.dll放入ruby200 \ bin中,然后将

gem install mysql2



这些是我在这里昏迷的结果吗?

 临时增强PATH以包含DevKit ... 
构建本机扩展。这可能需要一段时间...
错误:安装mysql2时出错:
错误:无法构建gem本机扩展。

C:/Ruby200/bin/ruby.exe extconf.rb
检查rb_thread_blocking_region()...是
检查rb_wait_for_single_fd()...是
检查rb_hash_dup()...是
检查rb_intern3()...是
*** extconf.rb失败***
由于某种原因无法创建Makefile,可能缺少必要的
库和/或标题。检查mkmf.log文件以获取更多详细信息。您可能
需要配置选项。

提供的配置选项:
--with-opt-dir
--without-opt-dir
--with-opt-include
- -without-opt-include = $ {opt-dir} / include
--with-opt-lib
--without-opt-lib = $ {opt-dir} / lib
--with-make-prog
--without-make-prog
--srcdir =。
--curdir
--ruby = C:/ Ruby200 / bin / ruby​​
--with-mysql-dir
--without-mysql-dir
- -with-mysql-include
--without-mysql-include = $ {mysql-dir} / include
--with-mysql-lib
--without-mysql-lib = $ {mysql-dir} /
extconf.rb:37:在< main>中:undefined方法`[]'为nil:NilClass(NoMethodError



Gem文件将保持安装在C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0中。
3.13用于检查。
记录到C的结果:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.13/ext/mysql2/g
em_make.out


解决方案

编辑30/09/2014



当这个答案发布时,64位rails安装程序不是推荐的版本 - 现在看来人们开始更多地使用它了。应该注意,当你下载MySQL连接器时,你需要下载64或32位来对应你安装的导轨版本。

令人惊讶的是,今天早上我很幸运地找到了答案,因为我碰巧正在寻找其他类似的东西。我不太清楚为什么没有一个简单的指南,因为它看起来非常直接!



由于某些原因,只需指定mysql-dir当你安装gem的时候并没有拿起其他的子目录,所以你需要手动设置参数。



对于遇到同样问题的其他人,我做了以下:

<1>从以下位置下载MySql C连接器: http: //dev.mysql.com/downloads/connector/c/



注意请勿下载安装程序,下载适用于您的操作系统的ARCHIVE
$ b 下载32位或64位ARCHIVE以符合您安装的导轨版本。



2)将文件解压到C:\ mysql-connector



3)然后运行:

  gem install mysql2 --platform = ruby​​  - '--with-mysql-lib =C:\mysql-connector\lib--with - mysql-include =C:\ mysql-connector\include--with-mysql-dir =C:\mysql-connector'

Voila一切正常。

编辑30/01/2014



我只需在砖机上进行全新安装,并且步骤3中的命令无效,那么工作是什么:

  gem install mysql2 --platform = ruby​​  - '--with-mysql-dir =C:\mysql-connector'

我不太确定区别是什么,但是这一次它似乎在拾取目录,所以如果第一个不行的试试这个!



我认为这与你如何安装rails有关,这一次我使用了railsinstaller,它似乎正确设置了路径。 b
$ b

这里的很多结果似乎取决于您使用的shell,很多人都遇到了powershell问题,所以我不建议使用它。我在一个提升的命令提示符下执行了这个操作。



哦,最后如果你在使用RAILS S的时候遇到mysql2 gem的错误,你需要将libmysql.dll从mysql连接器的LIB目录到已安装rails的bin目录。


I'm trying to installing the mysql2 gem on windows 7 I downloaded the connector from the mysql site and placed the libmysql.dll in ruby200\bin

then do gem install mysql2

These are the results am I being dim here?

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

    C:/Ruby200/bin/ruby.exe extconf.rb
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
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby200/bin/ruby
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/
extconf.rb:37:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError
)


Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.
3.13 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.13/ext/mysql2/g
em_make.out

解决方案

EDIT 30/09/2014

When this answer was posted the 64 bit rails installer wasn't the recommended version - it now seems people are starting to use it more. It should be noted when you download the MySQL Connector you need to download either 64 or 32bit to correspond to the version of rails you installed.

Amazingly I lucked upon an answer very early this morning as I happened to be looking for something else of a similar nature. I'm not quite sure why there isn't a single simple guide for this as it appears to be very straight forward!

For some reason just specifying the mysql-dir when you install the gem doesn't pick up with other sub directories so you need to set the parameters manually.

For anyone else experiencing the same problem, I did the following:

1) Download the MySql C Connector from: http://dev.mysql.com/downloads/connector/c/

NOTE Don't download the installer, download the ARCHIVE for your OS

Download either the 32bit or 64 bit ARCHIVE to correspond with the version of rails you installed.

2) Extract the file to C:\mysql-connector

3) Then ran:

 gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\mysql-connector\lib" --with-mysql-include="C:\mysql-connector\include" --with-mysql-dir="C:\mysql-connector"'

Voila everything is working fine.

EDIT 30/01/2014

I just had to do a fresh install on a bricked machine and the command in step 3 didn't work, what did work was:

gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\mysql-connector"'

I'm not quite sure what the difference is but this time it seems to be picking up the directories ok, so if the first one doesn't work try this one!

I think this has to do with how you go about installing rails, this time round I used the railsinstaller which seems to set the paths up correctly.

A lot of the outcome here seems to depend on the shell your using, a lot of people are having problems with powershell so I wouldn't advise using it. I did this in an elevated command prompt.

Oh and lastly if you get an error regarding the mysql2 gem when you do RAILS S you need to copy the libmysql.dll from the LIB directory of the mysql connector to the bin directory where rails has been installed.

这篇关于在Windows 7上安装Ruby MYSQL2 gem安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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