New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capistrano 3.6.0 breaks when used with Rake < 11.0.0, despite gemspec that allows it #1740

Closed
jesperrojestal opened this Issue Jul 28, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@jesperrojestal
Copy link

jesperrojestal commented Jul 28, 2016

Steps to reproduce

  1. Have rake version '>= 10.0.0' and '< 11..0.0' installed either via dependencies or specified in Gemfile
  2. Install Capistrano
  3. bundle exec cap -T --trace

Expected behaviour

Should show available capistrano tasks

Actual behaviour

cap aborted!
NoMethodError: undefined method `already_invoked' for <Rake::Task load:defaults => []>:Rake::Task
/home/current_user/shared/bundle/ruby/2.2.0/gems/capistrano-3.6.0/lib/capistrano/dsl.rb:16:in `invoke'
/home/current_user/shared/bundle/ruby/2.2.0/gems/capistrano-3.6.0/lib/capistrano/application.rb:91:in `load_imports'
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:697:in `raw_load_rakefile'
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:94:in `block in load_rakefile'
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:93:in `load_rakefile'
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:77:in `block in run'
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/home/current_user/shared/bundle/ruby/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
/home/current_user/shared/bundle/ruby/2.2.0/gems/capistrano-3.6.0/lib/capistrano/application.rb:14:in `run'
/home/current_user/shared/bundle/ruby/2.2.0/gems/capistrano-3.6.0/bin/cap:3:in `<top (required)>'
bin/cap:17:in `load'
bin/cap:17:in `<main>'

looking at line 16 of capistrano-3.6.0/lib/capistrano/dsl.rb reveals

      if task && task.already_invoked

Digging around the rake github repo reveals that Rake::Task#already_invoked is available only in 11.0.0, capistrano.gemspec specifies:

  gem.add_dependency "rake", ">= 10.0.0"

Your configuration

Gemfile contains

gem 'rake', '~> 10.5.0'
gem 'capistrano'

Paste Capistrano's doctor output here (cap <stage> doctor):

(Backtrace restricted to imported tasks)
cap aborted!
NoMethodError: undefined method `already_invoked' for <Rake::Task load:defaults => []>:Rake::Task

Tasks: TOP => staging
(See full trace by running task with --trace)

Workaround

Until gemspec/method is fixed, place rake in Gemfile with version above 11.0.0.

gem 'rake',  '~> 11.2.2'

@mattbrictson mattbrictson changed the title gemspec has invalid rake version Capistrano 3.6.0 breaks when used with Rake < 11.0.0, despite gemspec that allows it Jul 28, 2016

@mattbrictson

This comment has been minimized.

Copy link
Member

mattbrictson commented Jul 28, 2016

Thank you very much for the report! Yes, this is a serious bug.

@mattbrictson

This comment has been minimized.

Copy link
Member

mattbrictson commented Jul 28, 2016

@troelskn since this is related to your PR #1730, can you investigate and propose a fix for this? Perhaps we need to monkey patch Rake < 11 to expose already_invoked.

@mattbrictson

This comment has been minimized.

Copy link
Member

mattbrictson commented Jul 28, 2016

BTW, this is the Rake PR that exposed already_invoked: ruby/rake#93

@mattbrictson mattbrictson added this to the 3.6.1 milestone Jul 28, 2016

@troelskn

This comment has been minimized.

Copy link
Contributor

troelskn commented Jul 29, 2016

Yep. I'll take a look at it.

troelskn added a commit to troelskn/capistrano that referenced this issue Jul 29, 2016

troelskn added a commit to troelskn/capistrano that referenced this issue Jul 30, 2016

troelskn added a commit to troelskn/capistrano that referenced this issue Aug 3, 2016

mattbrictson added a commit that referenced this issue Aug 24, 2016

Merge pull request #1741 from troelskn/patch/1740
Added BC support for rake < 11. Resolves #1740
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment