开发者

Trying to install ruby-filemagic on Snow Leopard using brew rather than ports

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 ge开发者_如何学编程m 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/


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!


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/


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜