blackwinter / ruby-filemagic

Ruby bindings to the magic(4) library, revised.
https://blackwinter.github.iom/ruby-filemagic
146 stars 34 forks source link

What is the gem dependency?? #2

Closed millisami closed 13 years ago

millisami commented 13 years ago

Hi, I tried to install the gem but it blowed up with the native dependency. ree-1.8.7-2010.02 [~/gitcodes/httparty (master)] ➔ gem install ruby-filemagic Building native extensions. This could take a while... ERROR: Error installing ruby-filemagic: ERROR: Failed to build gem native extension.

/Users/millisami/.rvm/rubies/ree-1.8.7-2010.02/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
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/millisami/.rvm/rubies/ree-1.8.7-2010.02/bin/ruby
    --with-magic-dir
    --without-magic-dir
    --with-magic-include
    --without-magic-include=${magic-dir}/include
    --with-magic-lib
    --without-magic-lib=${magic-dir}/lib
    --with-magiclib
    --without-magiclib
***  ERROR: missing required library to compile this module

Gem files will remain installed in /Users/millisami/.rvm/gems/ree-1.8.7-2010.02/gems/ruby-filemagic-0.3.0 for inspection.
Results logged to /Users/millisami/.rvm/gems/ree-1.8.7-2010.02/gems/ruby-filemagic-0.3.0/ext/gem_make.out

What do I have to install first? I am on Mac OS X.

blackwinter commented 13 years ago

hi!

you need to have the header files for libmagic on your system for ruby-filemagic to be compiled. i'm not too familiar with os x, but you should get those when you install xcode.

hth jens

millisami commented 13 years ago

Well, thanx for the reply. I made it work by installing libmagic via brew and it works. But how can I get the extension?

Following is code and it works:

require 'filemagic'
require 'pp'

f = FileMagic.new
pp f.file("/Users/millisami/rubygems/spec/fixtures/not_csv_file.jpg")
pp f.file "/Users/millisami/rubygems/spec/fixtures/csv_input.csv"

And the result is:

"JPEG image data, JFIF standard 1.01"
"ASCII text"

But how can I get the extension of the file?

blackwinter commented 13 years ago

can you tell me what result you would have expected in each case? what do you mean by "extension"?

huobazi commented 9 years ago

the same error on osx ruby 2.2.2

when use

brew install libmagic

then it is OK

komalkishorvohra commented 8 years ago

For installing ruby-filemagic version 0.6.3 on OSX

env ARCHFLAGS="-arch x86_64" gem install -v 0.6.3 ruby-filemagic -- --with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/