Delayed Job error when using DataMapper as backend - ruby

I'm receiving a strange error when using DataMapper as the backend for Delayed Job. I am currently using the following gems:
delayed_job, 2.1.0.pre2
delayed_job_data_mapper, 1.0.0.rc
According to the instructions found here:
https://github.com/collectiveidea/delayed_job_data_mapper
I can successfully run
Delayed::Worker.backend = :data_mapper
Delayed::Worker.backend.auto_upgrade!
as well as enqueue objects into the database. However, when I try to run a rake task to run a worker, the workers starts successfully, but then when trying to decide what jobs to pull, gives the following error:
rake aborted!
expected a time or date, got Sun Feb 20 11:06:58 -0600 2011
It seems that this was previously reported as an issue on Github by someone else, but there's no solution, and the ticket is months old:
https://github.com/collectiveidea/delayed_job_data_mapper/issues#issue/1
[UPDATE] Someone posted an answer to the Github issue, which I have duplicated in my answer below this question.
So, my question is this: has anyone solved this error? Or is there a different way to do DataMapper + Delayed Job that I'm not aware of?
Full rake trace:
expected a time or date, got Sun Feb 20 11:08:56 -0600 2011
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/duration.rb:94:in `sum'
/Library/Ruby/Gems/1.8/gems/delayed_job-2.1.0.pre2/lib/delayed/worker.rb:33:in `inject'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/duration.rb:86:in `each'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/duration.rb:86:in `inject'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/duration.rb:86:in `sum'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/duration.rb:69:in `until'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/core_ext/time/calculations.rb:255:in `minus_without_coercion'
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/core_ext/time/calculations.rb:268:in `-'
/Library/Ruby/Gems/1.8/gems/delayed_job_data_mapper-1.0.0.rc/lib/delayed/backend/data_mapper.rb:35:in `find_available'
/Library/Ruby/Gems/1.8/gems/delayed_job-2.1.0.pre2/lib/delayed/worker.rb:172:in `reserve_and_run_one_job'
/Library/Ruby/Gems/1.8/gems/delayed_job-2.1.0.pre2/lib/delayed/worker.rb:101:in `work_off'
/Library/Ruby/Gems/1.8/gems/delayed_job-2.1.0.pre2/lib/delayed/worker.rb:100:in `times'
/Library/Ruby/Gems/1.8/gems/delayed_job-2.1.0.pre2/lib/delayed/worker.rb:100:in `work_off'
/Library/Ruby/Gems/1.8/gems/delayed_job-2.1.0.pre2/lib/delayed/worker.rb:75:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/Library/Ruby/Gems/1.8/gems/delayed_job-2.1.0.pre2/lib/delayed/worker.rb:74:in `start'
/Library/Ruby/Gems/1.8/gems/delayed_job-2.1.0.pre2/lib/delayed/worker.rb:71:in `loop'
/Library/Ruby/Gems/1.8/gems/delayed_job-2.1.0.pre2/lib/delayed/worker.rb:71:in `start'
Thanks!

stefanobernardi on Github gave this answer:
You need to require
"active_support/core_ext"
I haven't had a chance to try this out myself and see if it works since I ended up going with Resque instead, but I thought I would go ahead and post this answer in case anyone else comes across this question and actually wants a solution.

Related

YARD infinitely recurses on Ruby project

Ruby 3.0.0, YARD 0.9.28, Linux (Fedora 35).
Running yardoc on my project works through most of the tasks, but blows up with an apparent infinite recursion when it comes to the Serializing to doc/top-level-namespace.html. I had this problem earlier in development, but I have no idea what I did to make it go away — and now it's back.
It might have something to do with the convoluted interplay of include and extend uses; there are four modules in the project that get mixed into almost every source file in some combination or other. Regardless, this has me stumped, and I haven't found anything like it online.
Here's the tail-end of the processing (I had to pull it out of the Rake task and do it by hand because the Rake output didn't compress the repeating lines):
% bundle exec yardoc
:
:
[debug]: Parsing ["config/macros.yard", "lib/sptaf.rb", "lib/sptaf/classmethods.rb", "lib/sptaf/cli.rb", "lib/sptaf/container.rb", "lib/sptaf/debugging.rb", "lib/sptaf/exceptions.rb", "lib/sptaf/faction.rb", "lib/sptaf/feature.rb", "lib/sptaf/game.rb", "lib/sptaf/inventory.rb", "lib/sptaf/item.rb", "lib/sptaf/location.rb", "lib/sptaf/mixin/actor.rb", "lib/sptaf/mixin/container.rb", "lib/sptaf/mixin/location.rb", "lib/sptaf/mixin/thing.rb", "lib/sptaf/npc.rb", "lib/sptaf/player.rb", "lib/sptaf/version.rb"] with `ruby` parser
[debug]: Parsing config/macros.yard
[debug]: Parsing lib/sptaf.rb
[debug]: Parsing lib/sptaf/classmethods.rb
:
:
[debug]: Serializing to doc/top-level-namespace.html
bundler: failed to load command: yardoc (./vendor/bundle/ruby/3.0.0/bin/yardoc)
./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/proxy.rb:101:in `path': stack level too deep (SystemStackError)
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/proxy.rb:129:in `equal?'
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/module_object.rb:15:in `block in inheritance_tree'
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/module_object.rb:14:in `map'
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/module_object.rb:14:in `inheritance_tree'
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/proxy.rb:180:in `method_missing'
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/module_object.rb:17:in `block in inheritance_tree'
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/module_object.rb:14:in `map'
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/module_object.rb:14:in `inheritance_tree'
... 10681 levels...
from /usr/share/gems/gems/bundler-2.2.33/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
from /usr/share/gems/gems/bundler-2.2.33/libexec/bundle:37:in `<top (required)>'
from /home/coar/bin/bundle:23:in `load'
from /home/coar/bin/bundle:23:in `<main>'
Here is the .yardopts file it is using:
--charset="utf-8"
--verbose
--debug
--backtrace
--no-cache
--title="Text Adventure Framework (TAF) Gem"
--private
--embed-mixins
--markup-provider="rdiscount"
--markup="markdown"
config/macros.yard
lib/sptaf.rb
lib/sptaf/classmethods.rb
lib/sptaf/cli.rb
lib/sptaf/container.rb
lib/sptaf/debugging.rb
lib/sptaf/exceptions.rb
lib/sptaf/faction.rb
lib/sptaf/feature.rb
lib/sptaf/game.rb
lib/sptaf/inventory.rb
lib/sptaf/item.rb
lib/sptaf/location.rb
lib/sptaf/mixin/actor.rb
lib/sptaf/mixin/container.rb
lib/sptaf/mixin/location.rb
lib/sptaf/mixin/thing.rb
lib/sptaf/npc.rb
lib/sptaf/player.rb
lib/sptaf/version.rb
-
CHANGELOG.md
CODE_OF_CONDUCT.md
LICENCE.md
README.md
TODO.md
My apologies if the #documentation tag is inappropriate here; it says it's for questions about document generators, which seems to kinda fit.
As always, thanks for reading and particularly for any kind feedback!

RallyRestToolkitForRuby - Unable to pull user permissions

Am trying to use https://github.com/RallyTools/RallyRestToolkitForRuby to pull permissions of all users in my Rally Subscription. My authentication is through API Key. It fails with below error:
C:\Users\Administrator\Desktop\Rally-User-Management-master\Rally-User-Management-master>user_permissions_summary.rb
Connecting to Rally: https://rally1.rallydev.com/slm as ganra08#ca.com...
Running initial query of users...
Found a total of 12392 Enabled Users.
Summarizing users and writing permission summary output file...
C:/Users/Administrator/Desktop/Rally-User-Management-master/Rally-User-Management-master/lib/go_user_permissions_summary.rb:224:in block (2 levels) in go_user_permissions_summary'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rally_api-1.2.1/lib/rally_api/rally_colle
ction.rb:36:ineach'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rally_api-1.2.1/lib/rally_api/rally_collection.rb:36:in each'
C:/Users/Administrator/Desktop/Rally-User-Management-master/Rally-User-Management-master/lib/go_user_permissions_summary.rb:201:inblock in go_user_permissions_summary'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rally_api-1.2.1/lib/rally_api/rally_query_result.rb:22:in block in each'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rally_api-1.2.1/lib/rally_api/rally_query_result.rb:21:ineach'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rally_api-1.2.1/lib/rally_api/rally_query_result.rb:21:in each'
C:/Users/Administrator/Desktop/Rally-User-Management-master/Rally-User-Management-master/lib/go_user_permissions_summary.rb:180:ingo_user_permissions_summary'
C:/Users/Administrator/Desktop/Rally-User-Management-master/Rally-User-Management-master/user_permissions_summary.rb:38:in <main>' undefined method[]' for nil:NilClass
How do i get over this error? The Readme.pdf in the GitHub page provides no info about this.
Agile Central (formerly Rally) support helped to resolve this.
The $wsapi_version variable is set in a couple of places. We need to ensure that it is set to '1.43', and not 'v2.0'. Then the error went away and the script runs as expected.
If using the my_vars.rb file, comment out both lines of the $wsapi_version and just let the one in the go_user_permissions_summary.rb (1.43) be used.

Installing cloudfoundry gives Authentication error with Openstack; How can I debug an Opensource project? Namely, bosh on Openstack?

I am trying to create a Bosh Microinstance on my Rackspace Server and am getting the following error:
E, [2013-10-29T15:17:25.113723 #30341] [0xc9c00c] ERROR -- : Unable to connect to the OpenStack Compute API. Check task debug log for details.
I, [2013-10-29T16:38:36.928221 #1754] [0x335004] INFO -- : No existing deployments found (will save to /root/bosh-deployments.yml)
I, [2013-10-29T16:39:14.636310 #1768] [0xfa9010] INFO -- : Loading existing deployment data from: /root/bosh-workspace/deployments/bosh-deployments.yml
I, [2013-10-29T16:39:20.766583 #1768] [0xfa9010] INFO -- : bosh-registry is ready on port 25889
I, [2013-10-29T16:39:26.731953 #1768] [0xfa9010] INFO -- : Loading yaml from /tmp/d20131029-1768-ewe5t0/sc-20131029-1768-ansv2l/stemcell.MF
E, [2013-10-29T16:39:28.626135 #1768] [0xfa9010] ERROR -- : Expected([200, 204]) <=> Actual(401 Unauthorized)
response => #<Excon::Response:0x0000000382cdc0 #data={:body=>"{\"unauthorized\":{\"code\":401,\"message\":\"Unable to authenticate user with credentials provided.\"}}", :headers=>{"Server"=>"nginx/0.8.55", "Date"=>"Tue, 29 Oct 2013 16:39:27 GMT", "Content-Type"=>"application/json", "Transfer-Encoding"=>"chunked", "Connection"=>"keep-alive", "vary"=>"Accept, Accept-Encoding, X-Auth-Token", "VIA"=>"1.0 Repose (Repose/2.3.5)"}, :status=>401, :remote_ip=>"72.3.138.129"}, #body="{\"unauthorized\":{\"code\":401,\"message\":\"Unable to authenticate user with credentials provided.\"}}", #headers={"Server"=>"nginx/0.8.55", "Date"=>"Tue, 29 Oct 2013 16:39:27 GMT", "Content-Type"=>"application/json", "Transfer-Encoding"=>"chunked", "Connection"=>"keep-alive", "vary"=>"Accept, Accept-Encoding, X-Auth-Token", "VIA"=>"1.0 Repose (Repose/2.3.5)"}, #status=401, #remote_ip="72.3.138.129"> (Excon::Errors::Unauthorized)
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/excon-0.25.3/lib/excon/middlewares/expects.rb:10:in `response_call'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/excon-0.25.3/lib/excon/middlewares/response_parser.rb:8:in `response_call'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/excon-0.25.3/lib/excon/connection.rb:349:in `response'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/excon-0.25.3/lib/excon/connection.rb:247:in `request'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/core/connection.rb:57:in `request'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/core/deprecated/connection.rb:20:in `request'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/openstack.rb:195:in `retrieve_tokens_v2'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/openstack.rb:88:in `authenticate_v2'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/openstack/compute.rb:392:in `authenticate'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/openstack/compute.rb:316:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/core/service.rb:68:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/core/service.rb:68:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/compute.rb:44:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_openstack_cpi-1.5.0.pre.1181/lib/cloud/openstack/cloud.rb:55:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cpi-1.5.0.pre.1181/lib/cloud/provider.rb:11:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cpi-1.5.0.pre.1181/lib/cloud/provider.rb:11:in `create'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cli_plugin_micro-1.5.0.pre.1181/lib/bosh/deployer/configuration.rb:65:in `cloud'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cli_plugin_micro-1.5.0.pre.1181/lib/bosh/deployer/instance_manager.rb:54:in `cloud'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cli_plugin_micro-1.5.0.pre.1181/lib/bosh/deployer/instance_manager.rb:229:in `block (2 levels) in create_stemcell'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cli_plugin_micro-1.5.0.pre.1181/lib/bosh/deployer/instance_manager.rb:79:in `step'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cli_plugin_micro-1.5.0.pre.1181/lib/bosh/deployer/instance_manager.rb:228:in `block in create_stemcell'
/usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/tmpdir.rb:83:in `mktmpdir'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cli_plugin_micro-1.5.0.pre.1181/lib/bosh/deployer/instance_manager.rb:214:in `create_stemcell'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cli_plugin_micro-1.5.0.pre.1181/lib/bosh/deployer/instance_manager.rb:118:in `create'
"microbosh-openstack/bosh_micro_deploy.log" 215L, 28192C
I have a .yml file set up which I can't really post for security reasons, but I've verified with my IAAS support that i have the correct credentials.
Has anyone seen an error like this on Openstack? Also I am getting a stack trace and half tempted to try debugging. Problem is I'm not well versed on debugging these large open projects. Does anyone know a good resource explaining how to begin debugging them?
The error that you're seeing is caused by OpenStack rejecting the credentials that you're providing. One possible pitfall: are you using your Rackspace account password for "PASSWORD" instead of an API key? You can find your API key by logging in to your account, clicking on your username in the upper-right, and choosing "account settings" from the drop-down. (I'm assuming you're using Rackspace because of the question tags.)
You mentioned that you've verified them with your provider -- perhaps they aren't being passed in correctly? According to the documentation, you should put them in a micro_bosh.yml file with the following form:
# ...
cloud:
plugin: openstack
properties:
openstack:
auth_url: http://<identity_server>:5000/v2.0
username: <username>
api_key: <password>
tenant: <tenant>
region: <region> # Optional
default_security_groups: ["ssh", "bosh"]
default_key_name: <microbosh_keypair>
private_key: <path_to_microbosh_keypar_private_key>
# ...
Remember that YAML is whitespace-sensitive.
As for debugging open-source projects, the best guidance I can give is to not be afraid of the source and to have some patience. The source code for bosh is available on GitHub, so you can easily browse around the source code up your stack trace to try to figure out what's going on. Work backwards from the actual exception or error message that you're seeing; try to determine what was put into an unexpected state, and trace callers to figure out how it could have ended up that way. Reading other people's source code is an incredibly useful skill, and it gets easier with practice, so have at it!

irb --noprompt error with autoindent on

I like using the --noprompt option on irb sometimes, especially when I may want to copy code from it and paste it somewhere else. However, an error occurs when the following appears in the .irbrc file:
IRB.conf[:AUTO_INDENT] = true
The following error occurs when irb starts up:
/Users/keithb/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/irb.rb:280:in `dup': can't dup NilClass (TypeError)
from /Users/keithb/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/irb.rb:280:in `prompt'
from /Users/keithb/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/irb.rb:129:in `block in eval_input'
from /Users/keithb/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/irb/ruby-lex.rb:206:in `call'
from /Users/keithb/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/irb/ruby-lex.rb:206:in `prompt'
from /Users/keithb/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/irb/ruby-lex.rb:220:in `initialize_input'
from /Users/keithb/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/irb/ruby-lex.rb:227:in `each_top_level_statement'
from /Users/keithb/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/irb.rb:155:in `eval_input'
from /Users/keithb/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/irb.rb:70:in `block in start'
from /Users/keithb/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/irb.rb:69:in `catch'
from /Users/keithb/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/irb.rb:69:in `start'
from /Users/keithb/.rvm/rubies/ruby-1.9.3-p125/bin/irb:16:in `<main>'
The error also occurs in JRuby, but the stack trace is of course a bit different.
This is a bug, right? One would think an inappropriate configuration setting would be handled more gracefully, at minimum reporting the nature of the error at a higher level so the user would have an idea how to resolve it. Or could it be argued that it's the developer's fault for specifying an indent on a nonexistent prompt?
-- Keith
This is not a bug.
If you would like to have a .irbrc file ignored for special cases (such as when you want --noprompt) then you are likely also wanting to supply the -f flag to suppress loading your .irbrc file.
You will correctly get problems when supplying contradicting options.
TLDR;
irb -f --noprompt

Ruby networking problem on windows

I am running windows XP with ruby 1.8.6 patchlevel 111. I am using HTTP to connect to a remote server and it has been running fine. All of a sudden it started to through the exception listed below (I did not change any code since the last time I ran it successfully). Does anybody know what is going on?
c:/ruby/lib/ruby/1.8/timeout.rb:54:in `rbuf_fill': execution expired (Timeout::E
rror)
from c:/ruby/lib/ruby/1.8/timeout.rb:56:in `timeout'
from c:/ruby/lib/ruby/1.8/timeout.rb:76:in `timeout'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:126:in `readline'
from c:/ruby/lib/ruby/1.8/net/http.rb:2029:in `read_status_line'
from c:/ruby/lib/ruby/1.8/net/http.rb:2018:in `read_new'
from c:/ruby/lib/ruby/1.8/net/http.rb:1059:in `request'
... 19 levels...
from c:/ruby/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run'
from c:/ruby/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run'
from c:/ruby/lib/ruby/1.8/test/unit.rb:278
from c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader
.rb:5
rake aborted!
Command failed with status (3): [c:/ruby/bin/ruby -Ilib;test "c:/ruby/lib/r...]
Maybe the remote host is down? Or a new firewall has been put between your machine and the remote host?
"Timeout::Error" usually points to that direction.
besides the obvious (firewall, you got blacklisted for bad user-agent or ignoring robots.txt), you can try curl
http://curl.haxx.se/libcurl/ruby/
OR increase net/http timeout to say, 30+ seconds
http://groups.google.com/group/rubyonrails-talk/msg/cc89e8ae6703d6fb
It could be related to this known Ruby bug where Timeout::Error does not subclass Exception. (fixed in 1.9.2 I believe)
http://lindsaar.net/2007/12/9/rbuf_filltimeout-error
It can be fixed by rescuing from Timeout::Error like rescue Timeout::Error => e

Resources