2

I install whois using $ gem install whois and follow Ruby Whois
but when I test it in irb, it gives error:

1.9.3p194 :001 > c = Whois::Client.new
NameError: uninitialized constant Whois
from (irb):1
from /home/darshana/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
from /home/darshana/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
from /home/darshana/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>

EDIT

when I require 'whois' gives another error:

1.9.3p194 :003 > require 'whois'
LoadError: cannot load such file -- whois
from /home/darshana/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /home/darshana/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
from /home/darshana/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
from /home/darshana/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from (irb):3
from /home/darshana/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
from /home/darshana/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
from /home/darshana/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

Thanks.

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
Darshana
  • 2,462
  • 6
  • 28
  • 54

3 Answers3

2

Try to install and load the whois library .. that worked for me.

> gem install whois
> irb
* require 'whois'  
* c = Whois::Client.new
>>  #<Whois::Client:0x8f0fa34 @timeout=10, @settings={}>
Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
bulleric
  • 2,077
  • 6
  • 21
  • 36
  • I did that and gives me error `LoadError: cannot load such file -- whois` – Darshana Sep 04 '12 at 10:11
  • Have you installed the whois gem? – bulleric Sep 04 '12 at 10:16
  • yes. `darshana@darshana-pc:~/rails_projects/whois_test$ gem search whois *** LOCAL GEMS *** whois (2.6.4)` – Darshana Sep 04 '12 at 10:20
  • 1
    I think you are using the rails console not the irb console. Try to add the whois gem in your gemfile ( gem 'whois' ) run bundle then run the rails console and execute require 'whois' again – bulleric Sep 04 '12 at 10:22
1

Sometimes gems cant be required by default, for this time we need to require this gem.

For example(in your case), you added whois gem in Gemfile, then open console give following line

require "whois"

then use Whois constant should be available.

Mohanraj
  • 4,056
  • 2
  • 22
  • 24
  • I did that and gives me error `LoadError: cannot load such file -- whois` – Darshana Sep 04 '12 at 10:12
  • I think your installed gem is not included in your directory path, just go inside the gem find the whois.rb file. Then open irb give require "./whois". – Mohanraj Sep 04 '12 at 10:21
0

If this is in your gemfile than load the irb with bundle exec rails c

AnkitG
  • 6,438
  • 7
  • 44
  • 72