简体   繁体   中英

Simpler way of installing native dependencies than Heroku buildpacks?

I have a rails app with a dependency on the project-honeypot gem which in turn has the following dependencies according to my Gemfile.lock :

net-dns2 
  packetfu
    network_interface
    pcarub (~> 0.12)

When I push to my heroku app it won't install pcarub . Other sources lead me to the conclusion that I'm missing libpcap and libpcap-devel . I hope someone will correct me if I'm wrong here.

Unfortunately as far as I can see there is no way to run arbitrary apt-get commands, apart from the complexity of heroku buildpacks . Is there any simpler solution?

Heroku / pcarub install error:

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

Heroku buildpacks turned out to be extremely simple to use. Heroku now provides first class support for multiple buildpacks . I needed to set the ruby buildpack explicitly:

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

Then added heroku-buildpack-apt ahead of the ruby buildpack:

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

Then my dependency in a new file called Aptfile in the root of my project:

libpcap-dev

The next time I deployed Heroku used the new buildpack to apt-get install libpcap before running bundle install.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM