比Heroku buildpacks更简单的安装本机依赖项的方法?

时间:2015-10-08 05:46:06

标签: ruby-on-rails ruby ubuntu heroku apt-get

我有一个依赖于project-honeypot gem的rails应用程序,根据我的Gemfile.lock,它依次具有以下依赖关系:

net-dns2 
  packetfu
    network_interface
    pcarub (~> 0.12)

当我推送到我的heroku应用程序时,它将无法安装pcarubOther sources让我得出结论,我错过了libpcaplibpcap-devel。如果我在这里错了,我希望有人会纠正我。

不幸的是,除了heroku buildpacks的复杂性之外,我无法运行任意apt-get命令。有没有更简单的解决方案?

Heroku / pcarub安装错误:

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

    /app/vendor/ruby-2.0.0/bin/ruby extconf.rb

[*] Running checks for pcaprub_c code...
platform is x86_64-linux
checking for pcap_open_live() in -lpcap... no
checking for pcap_setnonblock() in -lpcap... no
creating Makefile

make "DESTDIR="
compiling pcaprub.c
pcaprub.c:8:18: fatal error: pcap.h: No such file or directory
 #include <pcap.h>
                  ^
compilation terminated.
make: *** [pcaprub.o] Error 1


Gem files will remain installed in /app/vendor/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/pcaprub-0.12.0 for inspection.
Results logged to /app/vendor/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/pcaprub-0.12.0/ext/pcaprub_c/gem_make.out

1 个答案:

答案 0 :(得分:1)

Heroku buildpacks使用起来非常简单。 Heroku现在提供first class support for multiple buildpacks。我需要明确设置ruby buildpack:

heroku buildpacks:set https://github.com/heroku/heroku-buildpack-ruby.git

然后在ruby buildpack之前添加heroku-buildpack-apt

heroku buildpacks:add --index 1 https://github.com/ddollar/heroku-buildpack-apt.git

然后我依赖于项目根目录中名为Aptfile的新文件:

libpcap-dev

下次我部署Heroku时,在运行bundle install之前将新的buildpack用于apt-get install libpcap