[Webistrano] Could not load tasks - syntax error in recipe definition?

150 views
Skip to first unread message

Guy

unread,
May 3, 2010, 1:20:08 PM5/3/10
to Webistrano
Hi,

I added a rollback task to the modified :deploy namespace for a recipe
and I get the following error message "Could not load tasks - syntax
error in recipe definition?". The recipe updates ok when I add the
rollback task, normally when there's an error it highlights the task
entry text area red and won't let me save the recipe, but I don't get
that in this case. I can save the recipe fine, but then in the stage
which makes use of the recipe there is only one task in the list,
called 'Error', with the above error message showing when I click
'Info'.

Guy

--
You received this message because you are subscribed to the Google Groups "Webistrano" group.
To post to this group, send email to webis...@googlegroups.com.
To unsubscribe from this group, send email to webistrano+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webistrano?hl=en.

Jonathan Weiss

unread,
May 4, 2010, 3:12:31 AM5/4/10
to webis...@googlegroups.com
> normally when there's an error it highlights the task
> entry text area red and won't let me save the recipe, but I don't get
> that in this case. I can save the recipe fine, but then in the stage
> which makes use of the recipe there is only one task in the list,
> called 'Error', with the above error message showing when I click
> 'Info'.

The check on saving checks only the syntax, when a recipe is loaded it
is executed. So you can have a recipe written in valid Ruby that still
blows up once executed.
You can uncomment some parts of the recipe until you find your problem.

Jonathan


--
Jonathan Weiss
http://blog.innerewut.de
http://twitter.com/jweiss

Guy

unread,
May 4, 2010, 4:40:52 PM5/4/10
to Webistrano
Ok, I've done some testing and the problem appears to be caused by
including my own rollback task in the recipe. This is within the
deploy namespace. My rollback task includes other tasks that rollback
db changes and revert symlinks, and the recipe is fine with these
tasks in it, but the minute I include the rollback task (even if it
doesn't call these other tasks at all!) I get the Error problem I
originally described.

Any ideas?

On May 4, 12:12 am, Jonathan Weiss <j...@innerewut.de> wrote:
> > normally when there's an error it highlights the task
> > entry text area red and won't let me save the recipe, but I don't get
> > that in this case. I can save the recipe fine, but then in the stage
> > which makes use of the recipe there is only one task in the list,
> > called 'Error', with the above error message showing when I click
> > 'Info'.
>
> The check on saving checks only the syntax, when a recipe is loaded it
> is executed. So you can have a recipe written in valid Ruby that still
> blows up once executed.
> You can uncomment some parts of the recipe until you find your problem.
>
> Jonathan
>
> --
> Jonathan Weisshttp://blog.innerewut.dehttp://twitter.com/jweiss

Jonathan Weiss

unread,
May 5, 2010, 3:22:46 AM5/5/10
to webis...@googlegroups.com
> Any ideas?

Not without seeing the recipe code. Does it also bail with an empty
rollback definition?

Jonathan

--
Jonathan Weiss
http://blog.innerewut.de

agbodike

unread,
May 19, 2010, 2:21:15 PM5/19/10
to Webistrano
I'm also seeing this, even with no recipes included, or even defined.
When I first installed I was able to see the task list (deploy:...),
but now, after creating a recipe and assigning it to a stage, all I
see in the "All Tasks" drop down is the task "Error" (this is in the
stage details view. I do see

Deploy
Deploy and migrate
Restart app servers
Setup

In the deployment box, and I am able to run those tasks, and they will
succeed, but there are non of the individual tasks avaialable in the
drop-down. If any more information will help you, let me know

I'm new to capistrano and webistrano,

On May 5, 12:22 am, Jonathan Weiss <j...@innerewut.de> wrote:
> > Any ideas?
>
> Not without seeing the recipe code. Does it also bail with an empty
> rollback definition?
>
> Jonathan
>
> --
> Jonathan Weisshttp://blog.innerewut.dehttp://twitter.com/jweiss

Jonathan Weiss

unread,
May 19, 2010, 3:35:56 PM5/19/10
to webis...@googlegroups.com
> I'm also seeing this, even with no recipes included, or even defined.
> When I first installed I was able to see the task list (deploy:...),
> but now, after creating a recipe and assigning it to a stage, all I
> see in the "All Tasks" drop down is the task "Error" (this is in the
> stage details view. I do see

You could add this in line 129 of app/models/stage.rb

instead of

def list_tasks
d = Deployment.new
d.stage = self
deployer = Webistrano::Deployer.new(d)
begin
deployer.list_tasks.collect { |t| {:name =>
t.fully_qualified_name, :description => t.description} }.delete_if{|t|
t[:name] == 'shell' || t[:name] == 'invoke'}
rescue
[{:name => "Error", :description => "Could not load tasks -
syntax error in recipe definition?"}]
end
end

use

def list_tasks
d = Deployment.new
d.stage = self
deployer = Webistrano::Deployer.new(d)
begin
deployer.list_tasks.collect { |t| {:name =>
t.fully_qualified_name, :description => t.description} }.delete_if{|t|
t[:name] == 'shell' || t[:name] == 'invoke'}
rescue
RAILS_DEFAULT_LOGGER.error("Problem listing tasks of stage
#{id}: #{e} - #{e.backtrace.join("\n")} ")
[{:name => "Error", :description => "Could not load tasks -
syntax error in recipe definition?"}]
end
end

This will log the real problem with the recipes.

Jonathan

--
Jonathan Weiss
http://blog.innerewut.de

Jonathan Weiss

unread,
May 19, 2010, 3:37:46 PM5/19/10
to webis...@googlegroups.com
Should have been:

def list_tasks
d = Deployment.new
d.stage = self
deployer = Webistrano::Deployer.new(d)
begin
deployer.list_tasks.collect { |t| {:name =>
t.fully_qualified_name, :description => t.description} }.delete_if{|t|
t[:name] == 'shell' || t[:name] == 'invoke'}
rescue Exception => e
RAILS_DEFAULT_LOGGER.error("Problem listing tasks of stage
#{id}: #{e} - #{e.backtrace.join("\n")} ")
[{:name => "Error", :description => "Could not load tasks -
syntax error in recipe definition?"}]
end
end

See also http://github.com/peritor/webistrano/commit/21b14b92b8982d19a754f4d8fca7e0bfb6b4f45d

agbodike

unread,
May 19, 2010, 4:15:32 PM5/19/10
to Webistrano
Great, looks like it's expecting at string, but getting nil...

here is the log output:

Problem listing tasks of stage 1: can't convert nil into String - /
home/deploy/webistrano/lib/webistrano/deployer.rb:147:in `sub!'
/home/deploy/webistrano/lib/webistrano/deployer.rb:147:in
`resolve_references'
/home/deploy/webistrano/lib/webistrano/deployer.rb:144:in `each'
/home/deploy/webistrano/lib/webistrano/deployer.rb:144:in
`resolve_references'
/home/deploy/webistrano/lib/webistrano/deployer.rb:131:in
`set_stage_configuration'
/home/deploy/webistrano/lib/webistrano/deployer.rb:130:in `each'
/home/deploy/webistrano/lib/webistrano/deployer.rb:130:in
`set_stage_configuration'
/home/deploy/webistrano/lib/webistrano/deployer.rb:114:in
`set_up_config'
/home/deploy/webistrano/lib/webistrano/deployer.rb:285:in `list_tasks'
/home/deploy/webistrano/app/models/stage.rb:127:in `list_tasks'
/home/deploy/webistrano/app/controllers/stages_controller.rb:17:in
`show'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
base.rb:1331:in `send'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
base.rb:1331:in `perform_action_without_filters'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
filters.rb:617:in `call_filters'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
filters.rb:638:in `run_before_filters'
/home/deploy/webistrano/app/controllers/application_controller.rb:
24:in `set_timezone'
/home/deploy/webistrano/vendor/rails/activesupport/lib/active_support/
callbacks.rb:178:in `send'
/home/deploy/webistrano/vendor/rails/activesupport/lib/active_support/
callbacks.rb:178:in `evaluate_method'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
filters.rb:186:in `call'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
filters.rb:635:in `run_before_filters'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
filters.rb:615:in `call_filters'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
filters.rb:610:in `perform_action_without_benchmark'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/home/deploy/webistrano/vendor/rails/activesupport/lib/active_support/
core_ext/benchmark.rb:17:in `ms'
/usr/local/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/home/deploy/webistrano/vendor/rails/activesupport/lib/active_support/
core_ext/benchmark.rb:17:in `ms'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
rescue.rb:160:in `perform_action_without_flash'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
flash.rb:146:in `perform_action'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
base.rb:532:in `send'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
base.rb:532:in `process_without_filters'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
filters.rb:606:in `process'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
base.rb:391:in `process'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
base.rb:386:in `call'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
routing/route_set.rb:437:in `call'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
dispatcher.rb:87:in `dispatch'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
dispatcher.rb:121:in `_call'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
dispatcher.rb:130:in `build_middleware_stack'
/home/deploy/webistrano/vendor/rails/activerecord/lib/active_record/
query_cache.rb:29:in `call'
/home/deploy/webistrano/vendor/rails/activerecord/lib/active_record/
query_cache.rb:29:in `call'
/home/deploy/webistrano/vendor/rails/activerecord/lib/active_record/
connection_adapters/abstract/query_cache.rb:34:in `cache'
/home/deploy/webistrano/vendor/rails/activerecord/lib/active_record/
query_cache.rb:9:in `cache'
/home/deploy/webistrano/vendor/rails/activerecord/lib/active_record/
query_cache.rb:28:in `call'
/home/deploy/webistrano/vendor/rails/activerecord/lib/active_record/
connection_adapters/abstract/connection_pool.rb:361:in `call'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
string_coercion.rb:25:in `call'
/usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in
`call'
/usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/
methodoverride.rb:24:in `call'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
params_parser.rb:15:in `call'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
session/cookie_store.rb:93:in `call'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
failsafe.rb:26:in `call'
/usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in
`call'
/usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in
`synchronize'
/usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in
`call'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
dispatcher.rb:114:in `call'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
reloader.rb:34:in `run'
/home/deploy/webistrano/vendor/rails/actionpack/lib/action_controller/
dispatcher.rb:108:in `call'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/rack/adapter/rails.rb:
74:in `call'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/connection.rb:
76:in `pre_process'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/connection.rb:
74:in `catch'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/connection.rb:
74:in `pre_process'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/connection.rb:
57:in `process'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/connection.rb:
42:in `receive_data'
/usr/local/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/
eventmachine.rb:256:in `run_machine'
/usr/local/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/
eventmachine.rb:256:in `run'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/backends/base.rb:
57:in `start'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/server.rb:156:in
`start'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/controllers/
controller.rb:80:in `start'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/runner.rb:177:in
`send'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/runner.rb:177:in
`run_command'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/runner.rb:143:in
`run!'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/bin/thin:6
/usr/local/bin/thin:19:in `load'
/usr/local/bin/thin:19


On May 19, 12:37 pm, Jonathan Weiss <j...@innerewut.de> wrote:
> Should have been:
>
> def list_tasks
>     d = Deployment.new
>     d.stage = self
>     deployer = Webistrano::Deployer.new(d)
>     begin
>       deployer.list_tasks.collect { |t| {:name =>
> t.fully_qualified_name, :description => t.description} }.delete_if{|t|
> t[:name] == 'shell' || t[:name] == 'invoke'}
>     rescue Exception => e
>       RAILS_DEFAULT_LOGGER.error("Problem listing tasks of stage
> #{id}: #{e} - #{e.backtrace.join("\n")} ")
>       [{:name => "Error", :description => "Could not load tasks -
> syntax error in recipe definition?"}]
>     end
>   end
>
> See alsohttp://github.com/peritor/webistrano/commit/21b14b92b8982d19a754f4d8f...
> Jonathan Weisshttp://blog.innerewut.dehttp://twitter.com/jweiss

Jonathan Weiss

unread,
May 20, 2010, 3:45:13 AM5/20/10
to webis...@googlegroups.com
On Wed, May 19, 2010 at 10:15 PM, agbodike <agbo...@gmail.com> wrote:
> Great, looks like it's expecting at string, but getting nil...

Can you try the following patch:

diff --git a/lib/webistrano/deployer.rb b/lib/webistrano/deployer.rb
index fdaa5c8..ae590c4 100644
--- a/lib/webistrano/deployer.rb
+++ b/lib/webistrano/deployer.rb
@@ -138,7 +138,7 @@ module Webistrano
end

def resolve_references(config, value)
- value = value.dup
+ value = value.dup.to_s
references = value.scan(/#\{([a-zA-Z_]+)\}/)
unless references.blank?
references.flatten.compact.each do |ref|



Jonathan


--
Jonathan Weiss
http://blog.innerewut.de
http://twitter.com/jweiss

--

agbodike

unread,
May 20, 2010, 2:45:18 PM5/20/10
to Webistrano
That didn't work, but If I make the following

if I change line 147 from:

value.sub!(/\#\{#{ref}\}/, conf_param_refence.value)
to:
value.sub!(/\#\{#{ref}\}/, '')

I'm able to see all the tasks in the dropdown, so it seems like the
conf_param_refence.value is coming back as nil in the
resolve_references method

here's a diff:

*** deployer.rb 2010-05-20 11:32:00.000000000 -0700
--- deployer.rb.bak 2010-05-20 10:29:12.000000000 -0700
***************
*** 144,150 ****
references.flatten.compact.each do |ref|
conf_param_refence =
deployment.effective_and_prompt_config.select{|conf| conf.name.to_s ==
ref}.first
if conf_param_refence
! value.sub!(/\#\{#{ref}\}/, '')
elsif config.exists?(ref)
build_in_value = config.fetch(ref)
value.sub!(/\#\{#{ref}\}/, build_in_value.to_s)
--- 144,150 ----
references.flatten.compact.each do |ref|
conf_param_refence =
deployment.effective_and_prompt_config.select{|conf| conf.name.to_s ==
ref}.first
if conf_param_refence
! value.sub!(/\#\{#{ref}\}/, conf_param_refence.value)
elsif config.exists?(ref)
build_in_value = config.fetch(ref)
value.sub!(/\#\{#{ref}\}/, build_in_value.to_s)


On May 20, 12:45 am, Jonathan Weiss <j...@innerewut.de> wrote:
> On Wed, May 19, 2010 at 10:15 PM, agbodike <agbod...@gmail.com> wrote:
> > Great, looks like it's expecting at string, but getting nil...
>
> Can you try the following patch:
>
> diff --git a/lib/webistrano/deployer.rb b/lib/webistrano/deployer.rb
> index fdaa5c8..ae590c4 100644
> --- a/lib/webistrano/deployer.rb
> +++ b/lib/webistrano/deployer.rb
> @@ -138,7 +138,7 @@ module Webistrano
>      end
>
>      def resolve_references(config, value)
> -      value = value.dup
> +      value = value.dup.to_s
>        references = value.scan(/#\{([a-zA-Z_]+)\}/)
>        unless references.blank?
>          references.flatten.compact.each do |ref|
>
> Jonathan
>
> --
> Jonathan Weisshttp://blog.innerewut.dehttp://twitter.com/jweiss

Jonathan Weiss

unread,
May 21, 2010, 2:56:44 AM5/21/10
to webis...@googlegroups.com
I've just commited a cleaner patch. Can you please test with the
current code from github?

Thanks,
Jonathan

--
Jonathan Weiss
http://blog.innerewut.de

agbodike

unread,
May 26, 2010, 4:13:22 PM5/26/10
to Webistrano
Hi, just wanted to let you know I got busy at work on other tasks and
haven't had a chance to debug further, but I hope to get back on it in
a couple days. In the meantime thank you very much for the assistance
you've provided!

On May 20, 11:56 pm, Jonathan Weiss <j...@innerewut.de> wrote:
> I've just commited a cleaner patch. Can you please test with the
> current code from github?
>
> Thanks,
> Jonathan
>
> --

> Jonathan Weisshttp://blog.innerewut.dehttp://twitter.com/jweiss

agbodike

unread,
May 27, 2010, 2:57:31 PM5/27/10
to Webistrano
OK, I applied the patch and that seems to have fixed it.

Thanks!

Jonathan Weiss

unread,
May 28, 2010, 2:50:16 AM5/28/10
to webis...@googlegroups.com
Great!

--

Reply all
Reply to author
Forward
0 new messages