我收到这个错误:
构建 native 扩展。这可能需要一段时间...
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,但我仍然遇到这些错误。我做错了什么?
最佳答案
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。在这种情况下,我认为它会起作用。
关于mysql - 在 mac 上用 rails3 安装 mysql2 gem 真的很奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5223003/