无法在 Lion 中安装 rmagick gem:gems 找不到 ruby.h
我已经全新安装了 Mac OS X Lion,并且安装了开发人员工具。我正在尝试安装一些红宝石宝石,但需要本机扩展的宝石未构建。
sudo gem install rmagick
例如不会构建。我收到此错误:
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
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
看起来 ruby.h 头文件已移动到 Lion 中,但我不知道如何将 ruby gems 指向它。
我还更新了 rubygems 本身
sudo gem update --system
,但问题仍然存在。有想法吗?
I've got a clean instal of Mac OS X Lion, and I've installed the Developer Tools. I'm trying to install some ruby gems and the ones which need native extensions aren't building.
sudo gem install rmagick
For example will not build. I get back this error:
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
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
It looks like the ruby.h header file has moved in Lion, but I don't know how to point ruby gems to it.
I've also updated rubygems itself with
sudo gem update --system
But the issue persists. Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,如果您仍在使用 sudo gem,您可能应该切换到 RVM,它管理大量红宝石和宝石集,所有这些都在您的主目录中,因此不存在权限问题,并且可以在它们之间干净地切换。
RVM:http://rvm.beginrescueend.com
其次,即使您说您“安装了开发人员工具”您可能还没有获得 XCode 和所有库。如今,XCode for Lion 已在 Mac App Store 上提供——值得庆幸的是,它是免费的,尽管几个月的价格为 4.99 美元,而且令人烦恼的是,Leopard 和 Snow Leopard 兼容版本的 XCode 还不 Mac 应用商店。
XCode: http://itunes.apple.com/us/app/ xcode/id448457090?mt=12
第三,rmagick依赖于ImageMagick。如今,实现这一点的最简单方法是通过 HomeBrew(MacPorts 曾经有过辉煌,但现在每个人都在酝酿)。
HomeBrew: 链接
毕竟,以下内容应该可以工作(并且刚刚在我的 Lion 笔记本电脑上为我工作):
First, if you're still using
sudo gem
, you should probably switch to RVM, which manages lots of rubies and gemsets, all in your home directory so there's no permission problems, and cleanly switches between them.RVM: http://rvm.beginrescueend.com
Second, even though you say you "installed the Developer Tools" you may not have gotten XCode and all the libraries. These days XCode for Lion is available on the Mac App Store -- for free, thankfully, though it was $4.99 for a few months, and annoyingly, the Leopard and Snow Leopard compatible versions of XCode are not on the Mac App Store.
XCode: http://itunes.apple.com/us/app/xcode/id448457090?mt=12
Third, rmagick depends on ImageMagick. The easiest way to get that these days is via HomeBrew (MacPorts had its day, but everybody's brewing now).
HomeBrew: Link
After all that, the following should work (and just now worked for me on my Lion laptop):