Ruby on Rails安装问题(Windows)

3

我安装了Ruby 2.0.0和DevKit,使用RuyInstaller进行安装。在创建新项目时出现错误信息:

rails new testtest -d mysql

..... a lot of output here ........

Installing mysql2 (0.3.14)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    C:/Ruby200/bin/ruby.exe extconf.rb
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
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** 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.

我该如何安装依赖项以使这个宝石没有任何错误?

请按照以下链接操作:http://stackoverflow.com/questions/9189628/install-ruby-on-rails-on-windows/22061523#22061523 - Pramod Patil
2个回答

9

您需要安装MySQL 32位(或MySQL Connector C),才能在Windows上编译mysql2 gem,即使您正在使用64位版本的操作系统。

请按照以下步骤操作:

  1. Download MySQL Server 32-bit .zip file (Alternatively MySQL Connector C is also fine)
  2. Copy libmysql.dll to %RUBY_HOME%\bin (or simply add MySQL 32-bit lib directory to PATH)
  3. Install mysql2 gem with --with-mysql-lib and --with-mysql-include options

    gem install mysql2 -- '--with-mysql-lib="c:\path\to\32-bit-MySQL-Server\lib\opt" --with-mysql-include="c:\\path\to\32-bit-MySQL-Server\include"'
    

2
谢谢。这真的很容易:gem install mysql2 -v 0.3.14 --platform=ruby -- --with-mysql-dir=C:\mysql - Dmitry

0
这是我的故事。我试图在Windows 7上使用devkit安装mysql2 gem。 首先,您需要安装连接器库和头文件。 不要使用默认文件夹“Program Files”,因为gem无法包含带有空格的文件夹。 我通过subst X:\“C:\ Program File \ Mysql Connector 6 C \”替换了连接器文件夹, 然后使用以下命令: gem install mysql2 -- --with-mysql-dir=X:\ 然后意识到我正在使用64位连接器库与32位ruby。 重新安装连接器。 然后gem成功安装。 但无法运行,抱怨缺少mysql dll。 所以,我将libmysql.dll和* .lib放入ruby \ bin文件夹中。 在所有这些之后,我能够使用mysql2 gem。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接