Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install libmagic on Heroku?

I have a rails 4 app that uses ruby-filemagic, and so filemagic needs to be installed on the system.

I've tried installing it on Heroku by mimicing solutions to this question, but it just won't work. I've tried multiple things, but the one I think is the most promising is installing via apt-get thanks to a combination of the (modified) apt-get, config and ruby buildpacks. In the config, I use BUNDLE_BUILD__RUBY-FILEMAGIC: --with-magic-dir=/app/.apt/usr/ --with-magic-include=/app/.apt/usr/include --with-magic-lib=/app/.apt/usr/lib

Eventually, I still get this:

  /tmp/build_29e629f8a00379850ab44096c10f1afc/vendor/ruby-2.0.0/bin/ruby extconf.rb --with-magic-dir=/tmp/build_29e629f8a00379850ab44096c10f1afc/.apt/usr/ --with-magic-include=/tmp/build_29e629f8a00379850ab44096c10f1afc/.apt/usr/include --with-magic-lib=/tmp/build_29e629f8a`00379850ab44096c10f1afc/.apt/usr/lib
   checking for main() in -lgnurx... no
   checking for magic_open() in -lmagic... no
   *** ERROR: missing required library to compile this module
   *** 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.

libmagic did get installed into this directory. Its contents are equivalent to the contents of the deb package, although it does seem quite light.

like image 330
ben Avatar asked Oct 19 '22 14:10

ben


2 Answers

You need to add the heroku-buildpack-magic buildpack before the main buildpack

heroku buildpacks:add --index 1 https://github.com/NetsoftHoldings/heroku-buildpack-magic.git

like image 110
Przemek Avatar answered Oct 22 '22 21:10

Przemek


I was able to get this working:

.buildpacks:

https://github.com/ddollar/heroku-buildpack-apt#master
https://github.com/heroku/heroku-buildpack-ruby.git#master

Aptfile:

libmagic-dev

The heroku-bundle-config was not necessary.

like image 27
kronezen Avatar answered Oct 22 '22 20:10

kronezen