2011-04-15 142 views
1

我到处搜索过,没有任何解决方案可以解决我的问题。我已经使用SQLite构建rails应用程序,但不是MySQL。对于这个特定的项目,我需要MySQL。当我尝试启动服务器时出现错误,所以我尝试安装MySQL的gems并得到另一个错误。有没有人有任何见解?谢谢!Ruby On Rails上的MySQL Gem

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 
+0

看起来你正在运行OSX ......哪个版本?你是否为你的OSX版本安装了开发工具(Xcode)? – brettish 2011-04-15 21:16:00

+0

你是如何在你的os x机器上安装mysql的? – Wes 2011-04-15 21:37:24

+0

OS X应该已经安装了MySQL ...但您也可以从[MySQL网站](http://www.mysql.com/downloads/mysql/)下载二进制文件。 – brettish 2011-04-15 21:53:38

回答

3

我有这个问题。您需要使用本机扩展来安装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/