我到处都找过了,没有人能解决我的问题。我使用SQLite构建rails应用程序,但不是MySQL。对于这个特殊的项目,我需要MySQL。当我试图启动服务器时,我得到一个错误,所以我试图安装MySQL的宝石,并得到另一个错误。有人有什么见解吗?谢谢你!
rails server
Could not find gem 'mysql2 (>= 0)' in any of the gem sources listed in your Gemfile.
sudo gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/ext/mysql2/gem_make.out
我遇到了这个问题。你需要安装带有本地扩展的mysql gem。
你要找的可能是这一行:
$ ARCHFLAGS="-arch x86_64" gem install mysql2 --version '~> 0.2.7' -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
详细介绍:http://softwaregravy.com/mysql-on-os-x-rails-3-0-7/