无法在OSX上安装gem mysql

时间:2012-08-13 15:38:34

标签: ruby macos rubygems

我无法在我的10.8(mac osx)机器上安装mysql gem。我用自制软件安装了mysql

$ brew install mysql

然后我做了:

$sudo gem install mysql
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

        /Users/marcinkrzyzanowski/.rvm/rubies/ruby-1.9.3-head/bin/ruby extconf.rb
checking for mysql_ssl_set()... *** 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
    --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=/Users/marcinkrzyzanowski/.rvm/rubies/ruby-1.9.3-head/bin/ruby
    --with-mysql-config
    --without-mysql-config
/Users/marcinkrzyzanowski/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/marcinkrzyzanowski/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
    from /Users/marcinkrzyzanowski/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
    from /Users/marcinkrzyzanowski/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
    from /Users/marcinkrzyzanowski/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/mkmf.rb:894:in `block in have_func'
    from /Users/marcinkrzyzanowski/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from /Users/marcinkrzyzanowski/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from /Users/marcinkrzyzanowski/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/marcinkrzyzanowski/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from /Users/marcinkrzyzanowski/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/marcinkrzyzanowski/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from /Users/marcinkrzyzanowski/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from /Users/marcinkrzyzanowski/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/mkmf.rb:893:in `have_func'
    from extconf.rb:50:in `<main>'


Gem files will remain installed in /Users/marcinkrzyzanowski/.rvm/gems/ruby-1.9.3-head/gems/mysql-2.8.1 for inspection.
Results logged to /Users/marcinkrzyzanowski/.rvm/gems/ruby-1.9.3-head/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

任何想法该做什么?

4 个答案:

答案 0 :(得分:2)

在升级到Mountain Lion之前,您是否安装了mysql?我有同样的问题,这解决了它:

brew uninstall mysql
brew install mysql
gem install mysql

答案 1 :(得分:1)

您需要一个C编译器来编译一些本机扩展。 (这是Ruby的要求。在gem使用C代码的更多情况下,你会看到这个错误)

  • 最简单的方法是安装Xcode
  • 但是如果您不仅仅是编译器,Xcode还有许多额外的实用程序,您可能不需要这些实用程序。有一个项目(现在由Apple支持)只安装名为Commandline tools for Xcode的命令行工具(各种编译器和东西)。安装此(或Xcode),然后尝试安装gem。

答案 2 :(得分:0)

我在后面试图从命令行安装mysql时感到很痛苦,所以我只是去了网站并得到了它。这是链接:http://dev.mysql.com/downloads

然后选择dmg版本并安装它。

这绝对是你想要接受的答案我打赌(同样在这里),但我不能这样做。

我在OS X 10.7.4

答案 3 :(得分:0)

我有完全相同的问题,所以让我们看看我们是否可以一起完成它。我已经浏览了大量Stack Overflow帖子,没有任何人建议工作。

  • XCode 4.6.3已安装
  • 从DMG安装的Mysql 5.6.12 x64
  • OSX 10.8.4
  • Ruby 2.0.0-p195

将Mysql安装到 / usr / local / mysql

尝试使用以下方法安装但没有成功:

sudo env ARCHFLAGS="-arch x86_64" gem install mysql --   --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib   --with-mysql-include=/usr/local/mysql/include

sudo find / -name mysql.h导致     /usr/local/mysql-5.6.12-osx10.7-x86_64/include/mysql.h

/ usr / local / mysql /usr/local/mysql-5.6.12-osx10.7-x86_64

的符号链接

我将继续努力,直到我能解决它,所以如果我遇到任何问题,我会发布它。