jjb / ruby-clock

A ruby job scheduler which runs jobs each in their own thread in a persistent process.
MIT License
78 stars 1 forks source link

Gem not working for me #29

Closed rvanrinsum closed 9 months ago

rvanrinsum commented 2 years ago

Hey man, this is exactly what I need, but I can't get it to work.

on bundle exec clock I get:

Clockfile:1:in `<top (required)>': uninitialized constant RubyClock::DSL (NameError)

using RubyClock::DSL
               ^^^^^

Tried a few things but no luck, any idea why this doesn't work out of the box? The binstub that it generated is this:

#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'clock' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
  if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
    load(bundle_binstub)
  else
    abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
  end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("ruby-clock", "clock")
rvanrinsum commented 2 years ago

actually, also before that uninitialized constant error, this is printed:

$ bundle exec clock
Because this is not a rails application, we do not know how to load your
rake tasks. You can do this yourself at the top of your Clockfile if you want
to run rake tasks from ruby-clock.
bundler: failed to load command: clock (/Users/xxxx/.asdf/installs/ruby/3.1.2/bin/clock)

Which is weird bc I'm in a Rails project dir

rvanrinsum commented 2 years ago

removing using RubyClock::DSL and using schedule.every ... fixed it. prob has to do with the different gem version

jjb commented 1 year ago

Hi @rvanrinsum

First of all sorry for the delayed response, I need to tweak my github notification preferences.

Glad you found a workaround. Not sure if you noticed the note at the top of the readme, which says the readme is for 2.0 beta. I should probably make that more visible, or maybe keep the beta stuff in another branch. sorry about that!

The good news is that since you wrote, the beta has improved quite a bit. you can use this in your gemfile

gem 'ruby-clock', tag: 'v2.0.0.beta9'

And everything in the readme here should work: https://github.com/jjb/ruby-clock

Or, if that doesn't work for you, you can use 1.0.0, and these instructions: https://github.com/jjb/ruby-clock/tree/v1.0.0

If you are currently on 1.0.0, look at the upgrade notes here: https://github.com/jjb/ruby-clock/blob/main/CHANGELOG.md

let me know if you have any problems!