升级到Lion,无法构建gem原生扩展

时间:2011-07-28 01:12:53

标签: macos rubygems osx-lion rmagick

不确定我的问题是否与此主题相关(http://stackoverflow.com/questions/6589066/rmagick-and-os-x-lion),但我刚刚升级到Lion;更具体地说,我购买了一台新机器,并通过我的旧配置文件迁移。

我无法启动rails 3,因为它无法找到rmagick,我无法安装rmagick,因为我收到以下错误。我尝试卸载rmagick和imageMagick,但在尝试捆绑安装时仍然遇到同样的错误。有什么想法吗? 谢谢

Installing rmagick (2.13.1) with native extensions /opt/local/lib/ruby/site_ruby/1.8/rubygems/installer.rb:551:in `build_extensions': ERROR:     Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

    /opt/local/bin/ruby extconf.rb 
checking for Ruby version >= 1.8.5... yes
checking for /usr/bin/gcc-4.2... no
No C compiler found in ${ENV['PATH']}. See mkmf.log for details.
*** 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=/opt/local/bin/ruby


Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/rmagick-2.13.1 for inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/installer.rb:504:in `each'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/installer.rb:504:in `build_extensions'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/installer.rb:180:in `install'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/source.rb:101:in `install'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/rubygems_integration.rb:78:in `preserve_paths'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/source.rb:91:in `install'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:58:in `run'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/rubygems_integration.rb:93:in `with_build_args'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:57:in `run'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/spec_set.rb:12:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/spec_set.rb:12:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:49:in `run'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:8:in `install'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/cli.rb:222:in `install'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/task.rb:22:in `send'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/task.rb:22:in `run'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/base.rb:389:in `start'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.15/bin/bundle:13
from /opt/local/bin/bundle:19:in `load'
from /opt/local/bin/bundle:19

UPDATE 所以我更新到Xcode4,当我brew --config时,它仍然表明我错过了GCC的东西:

HOMEBREW_VERSION: 0.8
HEAD: 8368fe489bde47b8f201bfcfdf328944fdf7092b
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
Hardware: quad-core 64-bit sandybridge
OS X: 10.7
Kernel Architecture: x86_64
Ruby: 1.8.7-249
/usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
Xcode: 
GCC-4.0: N/A 
GCC-4.2: N/A 

这怎么可能?

3 个答案:

答案 0 :(得分:6)

您似乎需要安装Xcode的Unix开发工具。

您可以在从Mac App Store安装Xcode时安装Unix工具:http://itunes.apple.com/us/app/xcode/id448457090?mt=12

答案 1 :(得分:4)

我已经尝试过这里提到的所有方法,没有任何帮助。 这节省了我的一天: https://gist.github.com/3182604

注意: 1.从首选项/下载更新XCode 2.安装X11.app 3.然后才修复ImageMagick gem

答案 2 :(得分:0)

来自https://github.com/mxcl/homebrew/wiki/Installation

的Homebrew安装说明

“1通过App Store进行安装仅适用于Lion用户。对于其他版本的Mac OS X,请参阅此处。如果您通过App Store进行安装,则需要运行”安装Xcode“应用程序放在/ Applications。