Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7924651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:51:31+00:00 2026-06-03T17:51:31+00:00

My problem is ruby recognizes require ‘packetfu’ and include PacketFu in IRB but does

  • 0

My problem is ruby recognizes require ‘packetfu’ and include PacketFu in IRB but does not work when I run it as a script. I want to know if it’s due to the way my gem directories are organized or if something odd is going on when I check-in as sudo to run the app.

Here is the error generated when I run it as a regular user:

  1 tMobile:~ cj3kim$ ruby packetfu.rb
  2 Simple sniffer for PacketFu 1.1.5
  3 /Users/cj3kim/.rvm/gems/ruby-1.9.3-p0/gems/packetfu-1.1.5/lib/packetfu/capture.rb:73:in `capture': Not root, so can't capture packets. Error:  (RuntimeError)
  4     from /Users/cj3kim/.rvm/gems/ruby-1.9.3-p0/gems/packetfu-1.1.5/lib/packetfu/capture.rb:46:in `setup_params'
  5     from /Users/cj3kim/.rvm/gems/ruby-1.9.3-p0/gems/packetfu-1.1.5/lib/packetfu/capture.rb:39:in `initialize'
  6     from packetfu.rb:9:in `new'
  7     from packetfu.rb:9:in `sniff'
  8     from packetfu.rb:20:in `<main>'

Does not work with sudo. Why?:

  9 The-BatMobile:~ cj3kim$ sudo ruby packetfu.rb
 10 /Users/cj3kim/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- packetfu (LoadError)
 11     from /Users/cj3kim/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
 12     from packetfu.rb:1:in `<main>'

Sample code from packetfu documentation for the simple sniffer program:

1 require 'packetfu'
  2 include PacketFu
  3 
  4 puts "Simple sniffer for PacketFu #{PacketFu.version}"
  5 
  6 iface = ARGV[0] || "en0"
  7 
  8 def sniff(iface)
  9         cap = Capture.new(:iface => iface, :start => true)
 10         cap.stream.each do |p|
 11                 pkt = Packet.parse p
 12                 if pkt.is_ip?
 13                         next if pkt.ip_saddr == Utils.ifconfig[:ip_saddr]
 14                         packet_info = [pkt.ip_saddr, pkt.ip_daddr, pkt.size, pkt.proto.last]
 15                         puts "%-15s -> %-15s %-4d %s" % packet_info
 16                 end
 17         end
 18 end
 19 
 20 sniff(iface)

Any help is appreciated. Thanks for looking!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T17:51:33+00:00Added an answer on June 3, 2026 at 5:51 pm

    Usually, it’s because the sudo environment can’t find any of your gems.

    If you’re using RVM (and you should: rvm.io ), you can use rvmsudo instead, and that will preserve your Ruby environment.

    If you can’t use RVM for whatever, reason, but you are using a modern version of sudo, you can try sudo -E to retain the environment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a problem getting a Ruby script to work correctly when run
I have a Linode (Ubuntu 9.10, but upgrading not a problem) where I run
I just have a problem with a ruby script I just want to change
Using Ruby 1.9.2 Problem Compare the content, not the results, of two procs. I
I've run into a strange problem with Ruby that I can't explain. I have
I want to implement highcharts in ruby on rails. But there's some runtime problem
Problem I am trying to build a small ruby script - which will be
I know this is not specific to tk, but rather a more general problem
I'm having a problem in ruby and I can't seem to find the solution
I'm currently facing this problem with ruby on rails 3, devise and facebook oauth.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.