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

cap -T throw error #14

Open
oayoub84 opened this issue Jul 11, 2016 · 4 comments
Open

cap -T throw error #14

oayoub84 opened this issue Jul 11, 2016 · 4 comments

Comments

@oayoub84
Copy link

Hi, after installing caphub and initializing the project, i've created the production.rb file in deploy/namespace/frontoffice/production.rb.

But the cap -T throw me an error:

cap aborted!
NoMethodError: undefined method gsub' for #<Proc:0x007fa56b3f9900> /usr/local/lib/ruby/gems/2.2.0/gems/capistrano-3.5.0/lib/capistrano/defaults.rb:2:inblock in <top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/capistrano-3.5.0/lib/capistrano/configuration/variables.rb:126:in call' /usr/local/lib/ruby/gems/2.2.0/gems/capistrano-3.5.0/lib/capistrano/configuration/variables.rb:126:inblock in invoke_validations'
/usr/local/lib/ruby/gems/2.2.0/gems/capistrano-3.5.0/lib/capistrano/configuration/variables.rb:125:in each' /usr/local/lib/ruby/gems/2.2.0/gems/capistrano-3.5.0/lib/capistrano/configuration/variables.rb:125:ininvoke_validations'
/usr/local/lib/ruby/gems/2.2.0/gems/capistrano-3.5.0/lib/capistrano/configuration/variables.rb:34:in set' /Users/USERNAME/www/deploy/config/deploy.rb:9:in<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.2.2/lib/rake/rake_module.rb:28:in load' /usr/local/lib/ruby/gems/2.2.0/gems/rake-11.2.2/lib/rake/rake_module.rb:28:inload_rakefile'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.2.2/lib/rake/default_loader.rb:10:in load' /usr/local/lib/ruby/gems/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:764:inload_imports'
/usr/local/lib/ruby/gems/2.2.0/gems/capistrano-3.5.0/lib/capistrano/application.rb:96:in load_imports' /usr/local/lib/ruby/gems/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:694:inraw_load_rakefile'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:96:in block in load_rakefile' /usr/local/lib/ruby/gems/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:178:instandard_exception_handling'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:95:in load_rakefile' /usr/local/lib/ruby/gems/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:79:inblock in run'
/usr/local/lib/ruby/gems/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:178:in standard_exception_handling' /usr/local/lib/ruby/gems/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:77:inrun'
/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

'

@ayanko
Copy link
Member

ayanko commented Jul 11, 2016

Could you show your file layout?

$ tree
$ ls -R

@oayoub84
Copy link
Author

.
├── Capfile
├── Gemfile
├── Gemfile.lock
├── config
│   ├── deploy
│   │   └── example.com
│   │   └── frontoffice
│   │   └── production.rb
│   └── deploy.rb
└── tasks

Capfile Gemfile Gemfile.lock config tasks

./config:
deploy deploy.rb

./config/deploy:
example.com

./config/deploy/example.com:
frontoffice

./config/deploy/example.com/frontoffice:
production.rb

./tasks:

@ayanko
Copy link
Member

ayanko commented Jul 14, 2016

This is because of stupid default validation for :application variable in capistrano 3.5 that does NOT consider the fact that variable can be a lambda.
https://github.com/capistrano/capistrano/blob/v3.5.0/lib/capistrano/defaults.rb#L1-L9

I suggest two solutions

Solution1. Remove stupid validation

config/deploy.rb

env.variables.send(:validators).delete(:application)
set :application, -> { fetch(:stage).split(':').reverse[1] }

Solution2. Use "static" application variable name

Remove dynamic application variable from config/deploy.rb and define it explicitly in each your stage. E.g.:

config/deploy/frontoffice.rb

set :application, 'frontoffice'

config/deploy/example_com.rb

set :application, 'example_com'

This is not DRY.

@taylorwilliams
Copy link

Thanks @ayanko - solution 1 solved it for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants