尝试使用brew而不是ports在Snow Leopard上安装ruby-filemagic

发布于 2024-09-08 07:01:14 字数 1094 浏览 3 评论 0原文

我正在尝试安装 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不寐倦长更 2024-09-15 07:01:14

你不必创建自己的公式,它在 libmagic 中。

brew install libmagic
brew link libmagic

然后,无论出于何种原因,gem 安装不起作用,但克隆库并运行

ruby extconf
make
make install

有效。天哪!

you don't have to make your own formula, it's there in libmagic.

brew install libmagic
brew link libmagic

then, for whatever reason the gem install didn't work but cloning the lib and running

ruby extconf
make
make install

worked. godspeed!

枕花眠 2024-09-15 07:01:14

这在 10.9 上对我有用: 通过 homebrew 在 Mac OS X 上安装 libmagic

简而言之:

brew install libmagic
brew link libmagic 
# If the link is already created is going to fail, dont worry about that
env ARCHFLAGS="-arch x86_64" gem install ruby-filemagic -- --with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/

This worked for me on 10.9: Install libmagic on Mac OS X via homebrew

In short:

brew install libmagic
brew link libmagic 
# If the link is already created is going to fail, dont worry about that
env ARCHFLAGS="-arch x86_64" gem install ruby-filemagic -- --with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/
×纯※雪 2024-09-15 07:01:14

是的,该教程中的命令(在某些方面)特定于 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文