Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

homebrew

ruby

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/

like image 563
user285429 Avatar asked Jul 06 '10 23:07

user285429


1 Answers

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!

like image 90
Michael Glass Avatar answered Nov 04 '22 01:11

Michael Glass