Radek
Radek

Reputation: 11121

How to solve " uninitialized constant Clockwork (NameError)"

I successfully installed gem clockwork

C:\web>gem install clockwork
Successfully installed clockwork-0.2.3
1 gem installed
Installing ri documentation for clockwork-0.2.3...
Installing RDoc documentation for clockwork-0.2.3...

but when running simple script

require 'rubygems'
require 'clockwork'
include Clockwork

every(1.minute, 'custom.event.handler' ) do
  puts "This event has its own handler - #{Time.new.strftime("%Y%m%d%H%M%S")}"
end

I get this error

C:\web>ruby clockwork.rb
./clockwork.rb:3: uninitialized constant Clockwork (NameError)
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
        from clockwork.rb:2

Any suggestion how to make clockwork work on

C:\web>gem list --local

*** LOCAL GEMS ***

aaronh-chronic (0.3.9)
activesupport (3.0.9)
backports (1.18.2)
clockwork (0.2.3)
daemons (1.1.0)
delayed_job (2.0.3)
eventmachine (0.12.10 x86-mswin32-60)
fastercsv (1.5.4)
haml (3.0.21)
i18n (0.6.0)
json (1.5.1)
mechanize (1.0.0)
monkey-lib (0.5.4)
nokogiri (1.5.0 x86-mingw32, 1.4.3.1 x86-mingw32)
rack (1.2.1)
rdiscount (1.6.8)
ruby-growl (3.0)
sinatra (1.2.6, 1.0)
sinatra-advanced-routes (0.5.1)
sinatra-reloader (0.5.0)
sinatra-sugar (0.5.1, 0.5.0)
thin (1.2.7 x86-mswin32)
tilt (1.3)

Upvotes: 0

Views: 1115

Answers (2)

anothernovice
anothernovice

Reputation: 1

you need to include the following in your clock.rb

require './config/boot' require './coonfig/environment'

Upvotes: 0

Casper
Casper

Reputation: 34328

Let me give you a hint. The name of your own program is clockwork.rb, and in it you do:

require 'clockwork'

See the problem?

Upvotes: 5

Related Questions