1

如果有什么不同,我只是更新到 Mountain Lion,我不知道这是否会使这个过程复杂化。

我正在尝试开始使用将连接到 MySql 数据库的 Sinatra 应用程序。我已经设置了 Gemfile 并正在运行 abundle install并获得以下输出:

Fetching gem metadata from http://rubygems.org/.....
Using haml (3.1.6) 
Installing mysql2 (0.3.11) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/Users/brad/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... *** 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/brad/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
 /Users/brad/.rvm/rubies/ruby-1.9.3-p194/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/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:894:in `block in have_func'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
         from /Users/brad/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:893:in `have_func'
         from extconf.rb:9:in `<main>'


 Gem files will remain installed in /Users/brad/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11 for inspection.
 Results logged to /Users/brad/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
 An error occured while installing mysql2 (0.3.11), and Bundler cannot continue.
 Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.

所以网上到处都说要下载mysql对吗?我得到了自制软件并运行了brew install mysql 据我所知,它是成功的。我有路径和文件夹之类的东西,但我没有 mysql_config 文件。任何地方。安装失败了吗?我需要做什么才能获得该文件?同样,我在 Mac 上,所以我不能apt-get install使用任何开发文件,这似乎对很多人有帮助。我很困惑。任何帮助都是极好的。

4

2 回答 2

1

重新编译 Ruby 解决了这个问题。支持 iltempo。不知道怎么给评论点赞...

于 2012-07-30T18:55:16.183 回答
0

您可以只xcode-select --install安装命令行工具,之后一切正常

于 2013-10-23T02:38:29.983 回答