Hanami: Removing mailer config causes showstopper exception

Created on 5 Mar 2017  路  5Comments  路  Source: hanami/hanami

Just started playing around with Hanami, making a small app that doesn't need to do any email, so I removed the mailer section from config/environment.rb, which looks like this (also removed the model section but hanami seems to work fine without that bit):

require 'bundler/setup'
require 'hanami/setup'
require_relative '../lib/code_analyser'
require_relative '../apps/web/application'

Hanami.configure do
  mount Web::Application, at: '/'

  environment :development do
    # See: http://hanamirb.org/guides/projects/logging
    logger level: :debug
  end

  environment :production do
    logger level: :info, formatter: :json
  end
end

which resulted in following exception when loading the homepage:

Boot Error

Something went wrong while loading /Users/andrew/code/code_analyser/config.ru

ArgumentError: wrong number of arguments (given 0, expected 1..3)

/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-mailer-1.0.0.beta1/lib/hanami/mailer.rb:61:in `instance_eval'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-mailer-1.0.0.beta1/lib/hanami/mailer.rb:61:in `configure'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components/components.rb:181:in `block (2 levels) in <module:Components>'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components/component.rb:42:in `call'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components.rb:85:in `block (2 levels) in resolve'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:133:in `block in fetch_or_store'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:122:in `fetch'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:132:in `fetch_or_store'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components.rb:83:in `block in resolve'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components.rb:82:in `each'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components.rb:82:in `resolve'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components/component.rb:136:in `resolve_requirements'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components/component.rb:34:in `call'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components.rb:85:in `block (2 levels) in resolve'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:133:in `block in fetch_or_store'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:122:in `fetch'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:132:in `fetch_or_store'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components.rb:83:in `block in resolve'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components.rb:82:in `each'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components.rb:82:in `resolve'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components/component.rb:136:in `resolve_requirements'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components/component.rb:34:in `call'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components.rb:85:in `block (2 levels) in resolve'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:133:in `block in fetch_or_store'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:122:in `fetch'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/map.rb:132:in `fetch_or_store'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components.rb:83:in `block in resolve'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components.rb:82:in `each'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/components.rb:82:in `resolve'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami.rb:94:in `boot'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami.rb:117:in `app'
/Users/andrew/code/code_analyser/config.ru:3:in `block in inner_app'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/builder.rb:55:in `instance_eval'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/builder.rb:55:in `initialize'
/Users/andrew/code/code_analyser/config.ru:1:in `new'
/Users/andrew/code/code_analyser/config.ru:1:in `inner_app'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:113:in `eval'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:113:in `inner_app'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:103:in `assemble_app'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:86:in `proceed_as_child'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:31:in `call!'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:18:in `call'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hanami-1.0.0.beta2/lib/hanami/assets/static.rb:49:in `call'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/lint.rb:49:in `_call'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/lint.rb:37:in `call'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/show_exceptions.rb:23:in `call'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.7.1/lib/puma/configuration.rb:232:in `call'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.7.1/lib/puma/server.rb:578:in `handle_request'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.7.1/lib/puma/server.rb:415:in `process_client'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.7.1/lib/puma/server.rb:275:in `block in run'
/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.7.1/lib/puma/thread_pool.rb:120:in `block in spawn_thread'

Using v1.0.0.beta2, following the getting started guide.

The expected behaviour for me would be for it to be ok with me removing that section from the config, ideally I'd be able to remove the loading of the mailer and it's dependencies altogether but just working without the config is good for now.

Keep up the great work 鉂わ笍

bug

All 5 comments

@andrew thanks for the feedback. I'm looking into this 馃憤

@andrew I created a simple fix for this issue. Could you use this version of hanami and check the problem?

gem 'hanami', github: 'hanami/hanami', branch: 'empty-mailer-config'

@davydovanton yeah that branch fixes the issue, thanks!

Fixed by #742

馃帀

Was this page helpful?
0 / 5 - 0 ratings

Related issues

duykhoa picture duykhoa  路  6Comments

leo-generali picture leo-generali  路  3Comments

nattfodd picture nattfodd  路  9Comments

cllns picture cllns  路  7Comments

mkarganov picture mkarganov  路  3Comments