【问题标题】:Really weird error installing mysql2 gem with rails3 on mac在mac上用rails3安装mysql2 gem真的很奇怪
【发布时间】:2011-03-07 17:32:28
【问题描述】:

我收到此错误:

构建原生扩展。这可能需要一段时间...

ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
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.

我已经尝试了所有here,但我仍然收到错误消息。出于某种原因,当我运行locate mysql_config 时,这是我得到的结果:

/Applications/MAMP/Library/bin/mysql_config /Applications/MAMP/Library/share/man/man1/mysql_config.1

我尝试使用每个路径运行sudo gem install mysql2 -- –with-mysql config=/path/you/identified/above/mysql_config 两次,但我仍然从上面得到错误。我下载了新版本的 MySql 并且我有 Xcode,但我仍然收到这些错误。我做错了什么?

【问题讨论】:

    标签: mysql ruby-on-rails ruby database installation


    【解决方案1】:

    MAMP 安装是你唯一安装的 mysql 吗?如果你是从 mysql 包安装的,那么我认为 mysql_config 将安装在 /usr/local/bin/mysql_config 中,所以你可能想尝试一下:

    sudo gem install mysql2 -- --with-mysql-config==/usr/local/bin/mysql_config

    仅供参考,/Applications/MAMP/Library/share/man/man1/mysql_config.1 路径显然是错误的。那是指向 mysql_config 的 man 文件,而不是实际的可执行文件。

    为了确定,您确实尝试过这个,对吗? (完全按照书面形式)

    sudo gem install mysql2 -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config

    另外,我不确定用 MAMP 打包的 mysql 是否有你需要的头文件。您最好从http://dev.mysql.com/downloads/mysql/ 安装mysql,然后尝试安装您的gem。在这种情况下,我认为它会起作用。

    【讨论】:

    • 有时安装旧版本的 mysql2 可以正常工作。
    猜你喜欢
    • 2011-08-14
    • 1970-01-01
    • 1970-01-01
    • 2011-11-16
    • 2012-11-18
    • 1970-01-01
    • 2011-12-03
    • 2012-08-07
    • 2014-02-03
    相关资源
    最近更新 更多