无论如何,我可以在没有Xcode的情况下为rails安装MySQL gem吗?许多网站都提到XCode是安装的可选要求。但是安装了命令行工具。
我已经安装了rails,ruby,自制软件,MacPorts没有XCode.但是MySql gem无法安装
。注意:我已经安装了Xcode的命令行工具。但不是完整的Xcode。
我遵循了这些参考资料,
http://scotty-t.com/2012/04/02/intstalling-mysql-5-5-on-os-x-mountain-lion/
在bash_profile设置路径
但是我在尝试时不断收到这些错误
sudo gem install mysql
错误
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby --with-mysql-config --without-mysql-config
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.9.0 for inspection. Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.9.0/ext/mysql_api/gem_make.out
我应该先安装 XCode 吗?提前感谢!
当你执行sudo gem install mysql
时,你正在安装一个命名mysql的gem
,而不是数据库。这个 gem 依赖于一个名为 libmysql
的文件,该文件随 mysql 数据库一起提供。
换句话说,您必须先在计算机上安装 mysql db,然后再安装 gem。否则,Gem 无法生成,因为它找不到所需的文件。
由于您有自制软件,因此您可以通过exec brew install mysql
安装mysql db。在那之后,sudo gem install mysql
可以工作了。
你已经安装了mysql-devel吗?如果没有,请尝试此操作
$ sudo yum install mysql-devel ;sorry it's for fedora
为狮子做,然后
$ gem install mysql
如果仍然存在错误,请尝试在安装 gem 时添加配置路径。