Skip to content
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

Setting :application to a Proc causes cap to crash #1681

Closed
mattbrictson opened this issue May 17, 2016 · 4 comments · Fixed by #1711 or #1744
Closed

Setting :application to a Proc causes cap to crash #1681

mattbrictson opened this issue May 17, 2016 · 4 comments · Fixed by #1711 or #1744
Assignees
Milestone

Comments

@mattbrictson
Copy link
Member

The logic used to validate :application expects a string value and will cause an exception to be raised otherwise. This prevents us from setting :application using a Proc, as originally reported here: capistrano/documentation#186

Steps to reproduce

  1. In deploy.rb, configure :application with a lambda, like this: set :application, -> { "myapp" }
  2. Run cap production deploy

Expected behaviour

The deploy should succeed with myapp used as the application name.

Actual behaviour

cap aborted!
NoMethodError: undefined method `gsub' for #<Proc:0x007f9aa311dd80@config/deploy.rb:1 (lambda)>
capistrano-3.5.0/lib/capistrano/defaults.rb:2:in `block in <top (required)>'
capistrano-3.5.0/lib/capistrano/configuration/variables.rb:126:in `block in invoke_validations'
capistrano-3.5.0/lib/capistrano/configuration/variables.rb:125:in `each'
capistrano-3.5.0/lib/capistrano/configuration/variables.rb:125:in `invoke_validations'
capistrano-3.5.0/lib/capistrano/configuration/variables.rb:34:in `set'
config/deploy.rb:1:in `<top (required)>'
@JohnSmall
Copy link

How come this is closed? It's definitely broken in version 3.5. I just upgraded from 3.4 to 3.5 and I get this error, even when I do cap -T, not even deploying.

Do we have to wait till the next bug fix release?

@mattbrictson
Copy link
Member Author

This issue was closed by PR #1711, which was merged on June 21. That means it is fixed in master and will be included in the next release. This is typical of most open source projects on GitHub, where issues are closed once they are fixed in the main development branch.

We don't have a fixed release schedule for Capistrano, so I can't promise when the next version will be published, but in the meantime you can point your Gemfile at the master branch:

gem "capistrano", :github => "capistrano/capistrano"

@mattbrictson
Copy link
Member Author

The fix in #1711, as reported by @deekthesqueak, is incomplete.

Specifically:

# Using a block works
set(:application) { ... }

# But using a proc or lambda still causes a crash
set :application, -> { ... }
# => NoMethodError: undefined method `gsub' for #<Proc>

@mattbrictson
Copy link
Member Author

mattbrictson commented Jul 30, 2016

Anyone affected by this bug please take a look at PR #1744 and let me know if it is a good fix for you. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment