capistrano / symfony

Capistrano tasks for deploying the Symfony standard edition
MIT License
353 stars 65 forks source link

What is the syntax to call a symfony command ? #61

Closed gido closed 6 years ago

gido commented 8 years ago

The README mention this:

namespace :deploy do
  task :migrate do
    symfony_console('doctrine:migrations:migrate', '--no-interaction')
  end
end

But when I use symfony_console in my own task I get this error:

** Invoke paris (first_time)
** Execute paris
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke deploy:set_symfony_env (first_time)
** Execute deploy:set_symfony_env
** Invoke opcache:clear (first_time)
** Execute opcache:clear
cap aborted!
NoMethodError: undefined method `execute' for main:Object
/usr/local/lib/ruby/gems/2.2.0/gems/capistrano-symfony-1.0.0.rc2/lib/capistrano/dsl/symfony.rb:52:in `symfony_console'
app/config/deploy.rb:53:in `block (2 levels) in <top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:248:in `call'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:248:in `block in execute'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `each'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `execute'
/usr/local/lib/ruby/gems/2.2.0/gems/airbrussh-1.0.1/lib/airbrussh/rake/context.rb:55:in `execute'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:180:in `invoke_with_call_chain'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:173:in `invoke'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:150:in `invoke_task'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `each'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block in top_level'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:115:in `run_with_threads'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:100:in `top_level'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:78:in `block in run'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
/usr/local/lib/ruby/gems/2.2.0/gems/capistrano-3.5.0/lib/capistrano/application.rb:14:in `run'
/usr/local/lib/ruby/gems/2.2.0/gems/capistrano-3.5.0/bin/cap:3:in `<top (required)>'
/usr/local/bin/cap:23:in `load'
/usr/local/bin/cap:23:in `<main>'
Tasks: TOP => opcache:clear

I'm using capistrano-symfony rc2 and capistrano 3.5.0. The CHANGELOG mention a change about symfony_console but I'm not sure to understand it.

Thanks for your help,

ninodafonte commented 8 years ago

Hi @gido,

I had this issue yesterday and as I didn't have too much time to dig into the code and see what's the real problem here, my workaround was to use the "old" way:

invoke 'symfony:console', 'doctrine:migrations:migrate', '--no-interaction', 'db' instead of the symfony:console(blabla) thing.

Hope this works for you in the meantime, I'll try to find out the real reason if nobody gets there before,

Cheers,

ps: after another try, it looks like enclosing the symfony:console command in a on roles clause, it works. I've read that has something to do with a syntax change in capistrano 3.x (sorry, I have almost no experience with ruby).

This works for me as well:

namespace :deploy do
  desc "Dumping assetic assets"
  task :assetic_dump do
    on roles(:all) do
      symfony_console "assetic:dump"
    end
  end
end
gido commented 8 years ago

Thanks for the reply. I used invoke and it work.

I wasn't aware about the role requirement (but it's a good thing to specify it in all case ;-)). I will update my recipes and try with this change.

danibram commented 7 years ago

Have same issue here, invoke save my life! thanks!

# OSX Sierra
# ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
# Capistrano Version: 3.8.1 (Rake Version: 12.0.0)

GEM
  remote: https://rubygems.org/
  specs:
    airbrussh (1.2.0)
      sshkit (>= 1.6.1, != 1.7.0)
    capistrano (3.8.1)
      airbrussh (>= 1.0.0)
      i18n
      rake (>= 10.0.0)
      sshkit (>= 1.9.0)
    capistrano-composer (0.0.6)
      capistrano (>= 3.0.0.pre)
    capistrano-file-permissions (0.1.1)
      capistrano (~> 3.1)
    capistrano-symfony (0.4.0)
      capistrano (~> 3.1)
      capistrano-composer (~> 0.0.3)
      capistrano-file-permissions (~> 0.1.0)
    i18n (0.8.1)
    net-scp (1.2.1)
      net-ssh (>= 2.6.5)
    net-ssh (4.1.0)
    rake (12.0.0)
    sshkit (1.13.1)
      net-scp (>= 1.1.2)
      net-ssh (>= 2.8.0)

PLATFORMS
  ruby

DEPENDENCIES
  capistrano
  capistrano-composer
  capistrano-file-permissions
  capistrano-symfony
  sshkit

BUNDLED WITH
   1.15.0
gido commented 7 years ago

Enclosing the symfony:console command in a on roles clause (which is the recommended way) solve the issue.

I'm closing it.

ChristianVermeulen commented 4 years ago

@gido I'm using:

# migrations.rake
namespace :deploy do
  task :migrate do
    on roles(:app) do
        symfony_console('doctrine:migrations:migrate', '--no-interaction')
    end
  end
end

As per your advice, yet still it is not finding this command. I also tried the "invoke" way, but that gives me the same result.

Caused by:
NoMethodError: undefined method `symfony_console' for #<SSHKit::Backend::Netssh:0x00007fcbe091f358>

I am on version 2.0.0. Could there be a problem after all?

gido commented 4 years ago

@ChristianVermeulen strange. The symfony_console is still here in 2.x.

Do you required the full recipe in your Capfile ?

# Capfile
# ...
require "capistrano/symfony"