blackwinter / ruby-filemagic

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

Missing development tools when installing 0.6.2 on OS X and Homebrew libmagic #13

Closed scarver2 closed 9 years ago

scarver2 commented 9 years ago

gem install ruby-filemagic fails. Tried the usual trick of env ARCHFLAGS="-arch x86_64" gem install ruby-filemagic -- --with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/ to no avail.

Confirmed that libmagic.1.dylib and libmagic.dylib are in /usr/local/lib/. What other dependencies does this gem have?

Building native extensions. This could take a while... ERROR: Error installing ruby-filemagic: ERROR: Failed to build gem native extension.

/Users/me/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20150206-87002-kyeyoq.rb extconf.rb

checking for main() in -lgnurx... * 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 --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/me/.rvm/rubies/ruby-2.2.0/bin/$(RUBY_BASE_NAME) --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-gnurx-dir --without-gnurx-dir --with-gnurx-include --without-gnurx-include=${gnurx-dir}/include --with-gnurx-lib --without-gnurx-lib=${gnurx-dir}/lib --with-gnurxlib --without-gnurxlib /Users/me/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:456:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /Users/me/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:541:intry_link0' from /Users/me/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:556:in try_link' from /Users/me/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:741:intry_func' from /Users/me/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:972:in block in have_library' from /Users/me/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:917:inblock in checking_for' from /Users/me/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:351:in block (2 levels) in postpone' from /Users/me/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:321:inopen' from /Users/me/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:351:in block in postpone' from /Users/me/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:321:inopen' from /Users/me/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:347:in postpone' from /Users/me/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:916:inchecking_for' from /Users/me/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:967:in have_library' from extconf.rb:9:in

'

extconf failed, exit code 1

Gem files will remain installed in /Users/me/.rvm/gems/ruby-2.2.0/gems/ruby-filemagic-0.6.2 for inspection. Results logged to /Users/me/.rvm/gems/ruby-2.2.0/extensions/x86_64-darwin-14/2.2.0/ruby-filemagic-0.6.2/gem_make.out

blackwinter commented 9 years ago

Due to #10 it also has a (soft) dependency on libgnurx now. Although I don't see why that would cause your error. Could you show me the mkmf.log file? (Gist or e-mail preferred) Could you try to compile without this line? (Unfortunately, I don't have an OS X environment to test on)

blackwinter commented 9 years ago

Are you sure your system is prepared to install extension gems at all? The note "You have to install development tools first" seems to indicate otherwise.

To compile the gem: Change to /Users/me/.rvm/gems/ruby-2.2.0/extensions/x86_64-darwin-14/2.2.0/ruby-filemagic-0.6.2 and run /Users/me/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20150206-87002-kyeyoq.rb extconf.rb to generate the Makefile. If that succeeds you can run make to compile.

One more thought to exclude the newly released version as the culprit: Can you install version 0.6.1? (gem install ruby-filemagic -v 0.6.1)

scarver2 commented 9 years ago

Here is the mkmf.log for 0.6.2 https://gist.github.com/scarver2/984dc271202ec2207302

0.6.1 installs without issue.

The folder /Users/me/.rvm/gems/ruby-2.2.0/extensions/x86_64-darwin-14/2.2.0/ruby-filemagic-0.6.2 only contains gem_make.out and mkmf.log. No other files present.

scarver2 commented 9 years ago

I forked 0.6.2 repo and issued a gem build ruby-filemagic.gemspec. It yielded this error: WARNING: See http://guides.rubygems.org/specification-reference/ for help ERROR: While executing gem ... (Gem::InvalidSpecificationException) ["lib/filemagic/magic.mgc"] are not files

Does this help?

blackwinter commented 9 years ago

clang: error: unsupported option '-static-libgcc'

Thanks, that line from mkmf.log says it all. Now we only need to find a way to avoid it.

The folder /Users/me/.rvm/gems/ruby-2.2.0/extensions/x86_64-darwin-14/2.2.0/ruby-filemagic-0.6.2 only contains gem_make.out and mkmf.log. No other files present.

Oh, I'm sorry, it should be /Users/me/.rvm/gems/ruby-2.2.0/gems/ruby-filemagic-0.6.2/ext/filemagic. And instead of removing this line I'd ask you to replace this line with:

$LDFLAGS << ' -static-libgcc' if RUBY_PLATFORM =~ /cygwin|mingw|mswin/

Does this help?

No, this only says that it can't find a particular file - which is dynamically generated during packaging.

scarver2 commented 9 years ago

That worked on OSX Yosemite. Testing on Windows now. Will report back ASAP.

blackwinter commented 9 years ago

Excellent! I've pushed the fix and will release a new version now. Thank you very much.

Testing on Windows now.

Let me stop you right there ;) Compiling on Windows is a tad more involved. That's what prompted this change in the first place (see #10).

scarver2 commented 9 years ago

Thank you for the fast response and resolution. A pleasure to work with you.