railsware / capistrano-multiconfig

Capistrano extension that allows to use multiple configurations
MIT License
65 stars 19 forks source link

Installing capistrano-multiconfig into development group (bundler) breaks rails 3 #6

Closed peterson closed 12 years ago

peterson commented 12 years ago

I'm using bundler in a rails 3 application. I had my capistrano gems installed in the "development" group in my Gemfile, and I added capistrano-multiconfig here as well:

group :development do
  gem 'capistrano'
  gem 'capistrano_colors'
  gem 'capistrano-multiconfig'
  gem 'capistrano-uptodate'
  gem 'capistrano-patch'
  gem 'capistrano-calendar'
end

In the above configuration, the "cap" task works fine, but when I attempt to invoke rails (e.g. rails c, or rails s), I receive an exception:

peterson@rutan:~/code/xxx$ rails s
/Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/capistrano-multiconfig-0.0.3/lib/capistrano/multiconfig/configurations.rb:1:in `load': wrong number of arguments (0 for 1) (ArgumentError)
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/capistrano-multiconfig-0.0.3/lib/capistrano/multiconfig/configurations.rb:1
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:239:in `require'
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:239:in `require'
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:239:in `require'
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/capistrano-multiconfig-0.0.3/lib/capistrano/multiconfig.rb:1
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/bundler-1.1.3/lib/bundler/runtime.rb:74:in `require'
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/bundler-1.1.3/lib/bundler/runtime.rb:74:in `require'
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each'
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require'
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/bundler-1.1.3/lib/bundler.rb:119:in `require'
from /Users/peterson/code/xxx/config/application.rb:15
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/railties-3.0.6/lib/rails/commands.rb:28:in `require'
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/railties-3.0.6/lib/rails/commands.rb:28
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/railties-3.0.6/lib/rails/commands.rb:27:in `tap'
from /Users/peterson/.rvm/gems/ruby-1.8.7-p334@xxx/gems/railties-3.0.6/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6

This appears to be caused by the following line (line 1) in capistrano-multiconfig-0.0.3/lib/capistrano/multiconfig/configurations.rb:

Capistrano::Configuration.instance.load do ...

Essentially this assumes whenever run that it has been called from capistrano. However if placed in the development group in a bundler Gemfile, this will be auto-loaded by rails whenever rails is run in development mode.

To resolve this, I have created a separate group in bundler for the deployment-related gems:

group :deployment do
  gem 'capistrano'
  gem 'capistrano_colors'
  gem 'capistrano-multiconfig'
  gem 'capistrano-uptodate'
  gem 'capistrano-patch'
  gem 'capistrano-calendar'
end

Ideally however it would be good if capistrano-multiconfig could be placed into the development group in a bundler Gemfile without this creating an exception when rails is invoked.

ayanko commented 12 years ago

v0.0.4