我是否可以在没有 Xcode 的情况下为 Rails 安装 MySQL gem?许多网站都提到 XCode 作为安装的可选要求。但命令行工具已安装。
我已经安装了rails,ruby,homebrew,MacPorts,但没有安装XCode。但是无法安装MySql gem
注意:我已经安装了 Xcode 的命令行工具。但不是完整的 Xcode。
我已遵循这些引用文献,
http://scotty-t.com/2012/04/02/intstalling-mysql-5-5-on-os-x-mountain-lion/
With setting path in 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
<strong>* extconf.rb failed *</strong>
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.
<p>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</p>
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 无法构建,因为它找不到所需的文件。
既然你有 Homebrew 软件,你可以通过exec brew install mysql
来安装mysql db。之后,sudo gem install mysql
就可以工作了。
关于mysql - 在没有 Xcode 的情况下使用 Rails 安装 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13820666/