Practical1
Practical1

Reputation: 678

ruby- packetgen installation gives gem install error

I'm trying to install packetgen, a library for crafting and manipulating network packets. I followed all the instructions, and installed all the necessary libraries. However, when I ran sudo gem install packetgen to install it on my Linux machine it raised an error:

ERROR:  Error installing packetgen:
ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.3.0/gems/pcaprub-0.12.4/ext/pcaprub_c
/usr/bin/ruby2.3 -r ./siteconf20181009-29130-us1azm.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/pcaprub-0.12.4                  for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0   /pcaprub-0.12.4/gem_make.out [here][1]

I ran the command as sudo, but got the same error. Does anyone know what I'm doing wrong here? The link to installation instructions is here.

Upvotes: 0

Views: 107

Answers (1)

lacostenycoder
lacostenycoder

Reputation: 11226

Don't use sudo gem install but rather it is highly recommended that you use a ruby version manager, probably RVM, for more reasons why, see 'sudo gem install' or 'gem install' and gem locations

Based on your error it looks like you're trying to use your system ruby which will likely have permission and/or library dependency issues. These are easily solved by using a version manager which has many advantages including the ability to use different ruby versions on the same system and not having to use sudo or root level installs of gems.

You can install RVM from here

Instructions on gem link you posted do say gem depends on sudo apt install libpcap-dev which is a system lib your gem needs to build. I assume you did that step already right?

Upvotes: 1

Related Questions