Godzilla74 Godzilla74 - 1 year ago 125
Ruby Question

LoadError on require

I have a simple ruby script that is using the

gem which I have installed with
gem install net-ping
and have confirmation that it has installed:

Successfully installed net-ping-1.7.8
Parsing documentation for net-ping-1.7.8
Done installing documentation for net-ping after 0 seconds
1 gem installed

In my script:
require 'net/ping'

def can_ping(host)
@icmp = Net::Ping::ICMP.new(host)
if @icmp.ping
can_ping = true
can_ping = false


In irb this all works fine, however when trying to run my script, it doesn't. Instead I get this error now:

/Users/golem/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- net/ping (LoadError)
from /Users/golem/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from checkin.rb:2:in `<main>'

This used to work fine on an older version of my script, however, I've since installed
on my Mac, which I suspect is the issue.

So, I made sure my environment variables reference RVM (


Is there something else that I'm missing that could be causing this?

Answer Source

So, net ping requires root privileges to run. So, if you are using sudo, the gem needs to be installed again. so, do sudo su first, run the gem install net-ping:1.7.8 again and try running your script.

That should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download