如何在 Heroku 上安装 libmagic?

How to install libmagic on Heroku?

我有一个使用 ruby-filemagic 的 rails 4 应用程序,因此需要在系统上安装 filemagic

我尝试通过模仿 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 构建包的解决方案将它安装在 Heroku 上。 在配置中,我使用 BUNDLE_BUILD__RUBY-FILEMAGIC: --with-magic-dir=/app/.apt/usr/ --with-magic-include=/app/.apt/usr/include --with-magic-lib=/app/.apt/usr/lib

最终,我还是明白了:

  /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 确实安装到此目录中。它的内容等同于deb包的内容,虽然它看起来确实很轻。

我能够让它工作:

.buildpacks:

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

应用程序文件:

libmagic-dev

heroku-bundle-config 不是必需的。

您需要在主 buildpack

之前添加 heroku-buildpack-magic buildpack

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