V3 Order of inclusion and "after/before"

39 views
Skip to first unread message

Carlos Peñas

unread,
Jul 9, 2014, 8:31:53 PM7/9/14
to capis...@googlegroups.com
Hi!.

I'm running in to the dared "cap aborted! Don't know how to build task '<task>'"

And I do not know if I'm missing something and is a feature or there's other way to get this

supose this deploy.rb

#after "deploy:restart", "clean:cache"

namespace deploy do
  task
:restart do
     
....
 
end
end

after "deploy:restart", "clean:cache"

and this lib/capistrano/tasks/clean.rake

namespace :clean do
  task :cache do
    ...
  end
end

#after "deploy:restart", "clean:cache"

all of these with the default Capfile which includes all the rake files in lib/capistrano

Documentation states that I  can put the after chain wherever it suits my needs (and I need to place it in the rake file) But it only works if I place it at the end of deploy.rb. Otherwise capistrano behaves like if task was undefined. This brings me to the old #include <stdio.h> times

is there a way to put after chain in the rake file or this one-pass evaluation is intended?

Versions:
  • Ruby ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-linux]
  • Capistrano   3.2.1
  • Rake / Rails / etc  rake, version 10.3., no rails
Platform:
  • Working on.... linux
  • Deploying to... vagrant linux

Carlos Peñas

unread,
Sep 29, 2014, 8:44:53 PM9/29/14
to capis...@googlegroups.com
Sure? no one? I came here to ask just this only to realize that I already asked it before...

Bruno Sutic

unread,
Sep 30, 2014, 8:49:27 AM9/30/14
to capis...@googlegroups.com
It seems you have a typo in the first code snippet above:

namespace deploy do
  task 
:restart do
     
....
  
end
end

The `namespace deploy` => deploy should be a symbol so try changing it to this: `namespace :deploy`

Carlos Peñas

unread,
Sep 30, 2014, 10:43:22 AM9/30/14
to capis...@googlegroups.com
mmm yes is a typo, but that's not the cause of malfunctioning

Look another example of this behaviour, just one stripped version of some deploy I'm building now:

Capfile:
require 'capistrano/setup'
require 'capistrano/deploy'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }


config/deploy.rb

lock '3.2.1'

set :application, 'my_app_name'
set :repo_url, 'asecretrepo.git'

namespace :deploy do
  desc
'Installs missing software'
  task
:install do
    puts
"Begin install"
 
end
end

#after 'deploy:install', 'base:install'  # this will work here if uncommented

lib/capistrano/tasks/base.rake

namespace :base do
  desc
"base install"
  task
:install do
    on roles
(:all) do
      puts
'aptitude update'
   
end
 
end
end

after
'deploy:install', 'base:install'  # this won't work here


This as it is, gives simply on a cap -vT

$ cap -vT
cap aborted
!
Don't know how to build task 'deploy:install'
/home/carlos/capifu/lib/capistrano/tasks/base.rake:10:in `<top (required)>'


But if you comment after in the rake task and uncomment the one in the config/deploy.rb it'll work as expected. But makes more sense specify the after/before hooks within the taks we want to be fired and not in another file.

Could this bi a limitation of the chosen "rake" path? or there's another way to do this?
Reply all
Reply to author
Forward
0 new messages