ruby-on-railsrubyruby-on-rails-4railtie

Bundler.require fails in clean Rails project


My rails app fails to load when I have the following line in application.rb:

Bundler.require(:default, Rails.env)

I get the following error:

.rvm/gems/ruby-2.0.0-p353@global/gems/railties-4.0.2/lib/rails/initializable.rb:13:in `[]': no implicit conversion of Symbol into Integer (TypeError)
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/railties-4.0.2/lib/rails/initializable.rb:13:in `initialize'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/railties-4.0.2/lib/rails/initializable.rb:85:in `new'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/railties-4.0.2/lib/rails/initializable.rb:85:in `initializer'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@rails-4.0/gems/rolify-3.3.0/lib/rolify/railtie.rb:6:in `<class:Railtie>'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@rails-4.0/gems/rolify-3.3.0/lib/rolify/railtie.rb:5:in `<module:Rolify>'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@rails-4.0/gems/rolify-3.3.0/lib/rolify/railtie.rb:4:in `<top (required)>'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@rails-4.0/gems/rolify-3.3.0/lib/rolify.rb:1:in `<top (required)>'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `require'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `each'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `block in require'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `each'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `require'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.1/lib/bundler.rb:131:in `require'
    from /Users/gerardkelly/Web Development/Rails Apps/Rails 4/po-app/config/application.rb:5:in `<top (required)>'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/railties-4.0.2/lib/rails/commands.rb:74:in `require'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/railties-4.0.2/lib/rails/commands.rb:74:in `block in <top (required)>'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
    from /Users/gerardkelly/.rvm/gems/ruby-2.0.0-p353@global/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Looks as though it's complaining about the params being sent in - which is odd because this is pre-baked Rails stuff. Note that the Bundler.require is application.rb:5 which its complaining about.

I'm on Rails 4, Ruby 2.0.0


Solution

  • Looks like the rollify gem you are using (so it's not clean rails project :P) has some issues in rails 4.x series. Check this out: https://github.com/EppO/rolify/pull/218 there is a fork that already fixes that.