尝试使用brew而不是ports在Snow Leopard上安装ruby-filemagic
我正在尝试安装 ruby-filemagic。
我尝试了 sudo gem install ruby-filemagic -v 0.2.2 并得到:
ERROR: Error installing ruby-filemagic:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for magic_open() in -lmagic... no
*** 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
--without-opt-dir
--with-opt-include
...
根据此: http://blog.elctech.com/2009/08/31/installing-ruby-filemagic-on-macos-x-and-ubuntu/
我需要 opt-dir 设置。 Opt 是针对 mac 端口的吧?我正在使用自制软件。
任何关于从这里去哪里的建议都会很棒。
直接从 gem 安装对我来说仍然不起作用,但以下命令可以: sudo env ARCHFLAGS="-arch x86_64" gem install ruby-filemagic -- --with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/
I'm trying to install ruby-filemagic.
I tried sudo gem install ruby-filemagic -v 0.2.2 and got:
ERROR: Error installing ruby-filemagic:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for magic_open() in -lmagic... no
*** 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
--without-opt-dir
--with-opt-include
...
According to this : http://blog.elctech.com/2009/08/31/installing-ruby-filemagic-on-macos-x-and-ubuntu/
I need the opt-dir setting. Opt is for mac ports right? And I'm using homebrew.
Any suggestions as to where to go from here would be great.
Installing directly from the gem still didn't work for me but the following command did:
sudo env ARCHFLAGS="-arch x86_64" gem install ruby-filemagic -- --with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你不必创建自己的公式,它在 libmagic 中。
然后,无论出于何种原因,gem 安装不起作用,但克隆库并运行
有效。天哪!
you don't have to make your own formula, it's there in libmagic.
then, for whatever reason the gem install didn't work but cloning the lib and running
worked. godspeed!
这在 10.9 上对我有用: 通过 homebrew 在 Mac OS X 上安装 libmagic
简而言之:
This worked for me on 10.9: Install libmagic on Mac OS X via homebrew
In short:
是的,该教程中的命令(在某些方面)特定于 MacPorts。该指南建议首先通过 MacPorts 安装必要的库,然后安装使用该库的 gem。乍一看,您没有该库,因此无法为 gem 构建扩展。另外,乍一看,Homebrew 似乎没有可供安装的库 - 尽管我不能 100% 确定这一点。
后续:来自同一个博客, 这是他关于如何使用 Homebrew 实现这一点的建议。简而言之,您需要创建自己所需的库的安装,然后就可以了。顺便说一句,他建议使用
sudo
,但您可能不需要或不希望使用 Homebrew(如果您以正常方式使用 Homebrew)。Yes, the commands from that tutorial are specific (in some ways) to MacPorts. The guide suggests first installing the necessary library via MacPorts, and then installing the gem that uses that library. At a glance, you don't have the library, so the extension can't be built for the gem. Also at a quick glance, Homebrew doesn't appear to have that library available for installation - though I'm not 100% sure of that.
Follow-up: From the same blog, here's his advice for how to do it with Homebrew. In a nutshell, you need to create your own installation of the library you need and then you should be ok. By the way, he suggests
sudo
, but you probably don't need or want that with Homebrew (if you use Homebrew in the normal way).