How to install libmagic on Heroku?

I have a rails 4 application that uses ruby-filemagic and therefore needs to be installed on the system.

I tried installing it on Heroku, picking up solutions to this issue , but that just wouldn't work. I tried several things, but the one that, in my opinion, is the most promising, is installed through apt-get thanks to the combination of (amended) apt-get , config, and ruby buildpacks. In 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

In the end, I still get the following:

  /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 indeed installed in this directory. Its contents are equivalent to the contents of the deb package, although it seems rather lightweight.

+5
source share
2 answers

I managed 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 

There was no need for a heroku-bundle-config file.

+1
source

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

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

+1
source

All Articles