设置Ruby on Rails应用程序。安装mysql gem的问题

时间:2012-02-13 21:50:14

标签: ruby-on-rails ruby rubygems

我正在尝试第一次设置rails。我已经制作了应用程序,我一直在关注很多指南。

当我尝试安装mysql gem gem install mysql

Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
        ERROR: Failed to build gem native extension.

        /usr/bin/ruby extconf.rb
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... no
checking for mysql/mysql.h... 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.

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=/usr/bin/ruby
        --with-mysql-config
        --without-mysql-config

环顾SO和Google,人们会说:

gem install mysql --with-mysql-config=/usr/bin/mysql_config

但我明白了:

ERROR:  While executing gem ... (OptionParser::InvalidOption)
    invalid option: --with-mysql-config=/usr/bin/mysql_config

关于如何让它发挥作用的任何想法?

1 个答案:

答案 0 :(得分:1)

如果您还没有,则需要以root身份安装MySQL开发库:

yum install mysql-devel

然后在gem install命令中你需要另一个 - 在--with-mysql-config选项之前的命令行中:

gem install mysql -- --with-mysql-config=/usr/bin/mysql_config