multiple included blocks error
bradherman opened this issue · 36 comments
I installed this gem in our project recently and shaved 4.5s off our boot time... However, some engineers began experiencing the following error when trying to run the app... Out of 35 engineers or so, only 4-5 had this issue, but we couldn't identify any setup differences on our machines...
Rails 4.2.x with the regeneration block in our initializer like shown in the docs... Any ideas?
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/concern.rb:126:in `included': Cannot define multiple 'included' blocks for a Concern (ActiveSupport::Concern::MultipleIncludedBlocks)
from /usr/local/Cellar/rbenv/0.4.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-3.5.6/lib/devise/models/authenticatable.rb:62:in `<module:Authenticatable>'
from /usr/local/Cellar/rbenv/0.4.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-3.5.6/lib/devise/models/authenticatable.rb:54:in `<module:Models>'
from /usr/local/Cellar/rbenv/0.4.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-3.5.6/lib/devise/models/authenticatable.rb:6:in `<module:Devise>'
from /usr/local/Cellar/rbenv/0.4.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-3.5.6/lib/devise/models/authenticatable.rb:5:in `<top (required)>'
smells like a duplicate load issue ...
add this to the top of the file and see where it is called from
puts ">>>>>>>>#{__FILE__}:#{__LINE__}>>>>>>>>"
puts caller
puts "<<<<<<<<#{__FILE__}:#{__LINE__-2}<<<<<<<<"
most likely loaded via distinct absolute paths / symlinks etc foobar ...
On Mon, May 16, 2016 at 2:46 PM, Bradley Herman notifications@github.com
wrote:
I installed this gem in our project recently and shaved 4.5s off our boot
time... However, some engineers began experiencing the following error when
trying to run the app... Out of 35 engineers or so, only 4-5 had this
issue, but we couldn't identify any setup differences on our machines...Rails 4.2.x with the regeneration block in our initializer like shown in
the docs... Any ideas?/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/concern.rb:126:in
included': Cannot define multiple 'included' blocks for a Concern (ActiveSupport::Concern::MultipleIncludedBlocks) from /usr/local/Cellar/rbenv/0.4.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-3.5.6/lib/devise/models/authenticatable.rb:62:in
module:Authenticatable'
from /usr/local/Cellar/rbenv/0.4.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-3.5.6/lib/devise/models/authenticatable.rb:54:in<module:Models>' from /usr/local/Cellar/rbenv/0.4.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-3.5.6/lib/devise/models/authenticatable.rb:6:in
module:Devise'
from /usr/local/Cellar/rbenv/0.4.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-3.5.6/lib/devise/models/authenticatable.rb:5:in `<top (required)>'—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#36
Yes definitely something required twice. Also since the backtrace shows you are on OSX, be aware that HFS is case-insensitive and as such, require 'foo'; require 'FOO'
will require twice the same file under MRI. that might be something along those lines happening.
Please let us know if you figure it out or discover more clues.
Also just to complement @grosser's answer, it's at /usr/local/Cellar/rbenv/0.4.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-3.5.6/lib/devise/models/authenticatable.rb:62
that you want to put that debug statement.
I'm also hitting this, but when deploying to a Linux server
Interesting. Same version of devise?
Devise 3.5.9, but it seems to fall over in a way that does not implicate Devise for me; instead, it is paper_trail
that is implicated.
Could you follow @grosser indications and report the backtraces here? As long as we can't reproduce your problem, we can't fix it.
This is a typical error log:
Message from application: Cannot define multiple 'included' blocks for a Conce
rn (ActiveSupport::Concern::MultipleIncludedBlocks)
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/a
ctive_support/concern.rb:126:in `included'
/mnt/data/sites/staging.bilgo/shared/bundle/ruby/2.3.0/gems/paper_trail-5.1.0/
lib/paper_trail/version_concern.rb:12:in `<module:VersionConcern>'
/mnt/data/sites/staging.bilgo/shared/bundle/ruby/2.3.0/gems/paper_trail-5.1.0/
lib/paper_trail/version_concern.rb:9:in `<module:PaperTrail>'
/mnt/data/sites/staging.bilgo/shared/bundle/ruby/2.3.0/gems/paper_trail-5.1.0/
lib/paper_trail/version_concern.rb:4:in `<top (required)>'
/mnt/data/sites/staging.bilgo/shared/bundle/ruby/2.3.0/gems/bootscale-0.5.1/li
b/bootscale/core_ext.rb:4:in `require'
/mnt/data/sites/staging.bilgo/shared/bundle/ruby/2.3.0/gems/bootscale-0.5.1/li
b/bootscale/core_ext.rb:4:in `require'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/a
ctive_support/dependencies.rb:274:in `block in require'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/a
ctive_support/dependencies.rb:240:in `load_dependency'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/a
ctive_support/dependencies.rb:274:in `require'
/mnt/data/sites/staging.bilgo/shared/bundle/ruby/2.3.0/gems/paper_trail-5.1.0/
lib/paper_trail/frameworks/active_record/models/paper_trail/version.rb:1:in `<to
p (required)>'
/mnt/data/sites/staging.bilgo/shared/bundle/ruby/2.3.0/gems/bootscale-0.5.1/li
b/bootscale/core_ext.rb:4:in `require'
/mnt/data/sites/staging.bilgo/shared/bundle/ruby/2.3.0/gems/bootscale-0.5.1/li
b/bootscale/core_ext.rb:4:in `require'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/a
ctive_support/dependencies.rb:274:in `block in require'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/a
ctive_support/dependencies.rb:240:in `load_dependency'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/a
ctive_support/dependencies.rb:274:in `require'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/a
ctive_support/dependencies.rb:360:in `require_or_load'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/a
ctive_support/dependencies.rb:317:in `depend_on'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/a
ctive_support/dependencies.rb:233:in `require_dependency'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/
engine.rb:472:in `block (2 levels) in eager_load!'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:471:in `each'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:471:in `block in eager_load!'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:469:in `each'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:469:in `eager_load!'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:346:in `eager_load!'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/application/finisher.rb:56:in `each'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `instance_exec'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `run'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
/usr/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/usr/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
/usr/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
/usr/lib/ruby/2.3.0/tsort.rb:347:in `each'
/usr/lib/ruby/2.3.0/tsort.rb:347:in `call'
/usr/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
/usr/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
/usr/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:54:in `run_initializers'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/application.rb:352:in `initialize!'
/mnt/data/sites/staging.bilgo/releases/20160525074918/config/environment.rb:5:in `<top (required)>'
config.ru:3:in `require'
config.ru:3:in `block in <main>'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
/var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `eval'
/usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `<module:App>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'
Yeah we know. But that doesn't help. What we want to see is the backtrace of when it was first called.
Can you edit /var/www/staging.bilgo/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/a ctive_support/concern.rb:126
to put:
puts ">>>>>>>>#{__FILE__}:#{__LINE__}>>>>>>>>"
puts caller
puts "<<<<<<<<#{__FILE__}:#{__LINE__-2}<<<<<<<<"
In there and report the backtraces?
Thank you very much for this, however I'm sorry, I'm meant to ask you to put that debug in /mnt/data/sites/staging.bilgo/shared/bundle/ruby/2.3.0/gems/paper_trail-5.1.0/ lib/paper_trail/version_concern.rb:12
. I shouldn't have answered before my coffee :/
What I can already see from this logs, is that it seems passenger doesn't load config/boot.rb
, but that seems really weird.
Ok, so digging a bit in that backtrace, it seems passenger is loading Bundler itself: https://github.com/phusion/passenger/blob/55b768b5cb1a115dcbdd3dccb3b0d25358e9b2a0/src/ruby_supportlib/phusion_passenger/loader_shared_helpers.rb#L238-L299
So I'll have to investigate passenger's compatibility, but as of now it's seems unlikely.
Actually passenger might be giving us a solution: https://github.com/phusion/passenger/blob/55b768b5cb1a115dcbdd3dccb3b0d25358e9b2a0/src/ruby_supportlib/phusion_passenger/loader_shared_helpers.rb#L266-L267
I won't have time to test this before tonight, but if I understand the situation correctly, putting:
require_relative './boot.rb'
in config/setup_load_paths.rb
might fix your issue.
I also wonder if it's indeed the same issue than @bradherman, because form the original reported issue it seems the error was happening in development, and I doubt they are running passenger in development.
Very interesting --- we don't see the issue in development, where passenger is not used
I probably won't have a chance to look at this until tomorrow now, but I will try using a config/setup_load_paths.rb
as you suggest.
I had the same issue with the paper_trail gem. And I figured out how to apply the patch there. This is the pr. But, unfortunately, it hasn't been approved because its maintainers claim that the issue is actually in bootscale
gem itself. It just breaks standard Ruby's behavior. I just leave this message here, because, I think, it can be helpful to fix the real issue.
Interesting, but even bootscale should require that file twice. Is bootscale properly at the top of your Gemfile?
Putting it on the top doesn't change anything. The issue arises when I try to run rspec. I can paste here the full backtrace:
ActiveSupport::Concern::MultipleIncludedBlocks:
Cannot define multiple 'included' blocks for a Concern
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/concern.rb:126:in `included'
# /usr/local/Cellar/rbenv/1.1.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/paper_trail-5.2.2/lib/paper_trail/version_concern.rb:12:in `<module:VersionConcern>'
# /usr/local/Cellar/rbenv/1.1.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/paper_trail-5.2.2/lib/paper_trail/version_concern.rb:9:in `<module:PaperTrail>'
# /usr/local/Cellar/rbenv/1.1.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/paper_trail-5.2.2/lib/paper_trail/version_concern.rb:4:in `<top (required)>'
# /usr/local/Cellar/rbenv/1.1.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bootscale-0.5.2/lib/bootscale/core_ext.rb:4:in `require'
# /usr/local/Cellar/rbenv/1.1.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bootscale-0.5.2/lib/bootscale/core_ext.rb:4:in `require'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `block in require'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in `load_dependency'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `require'
# /usr/local/Cellar/rbenv/1.1.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/paper_trail-5.2.2/lib/paper_trail/frameworks/active_record/models/paper_trail/version.rb:1:in `<top (required)>'
# /usr/local/Cellar/rbenv/1.1.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bootscale-0.5.2/lib/bootscale/core_ext.rb:4:in `require'
# /usr/local/Cellar/rbenv/1.1.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bootscale-0.5.2/lib/bootscale/core_ext.rb:4:in `require'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `block in require'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in `load_dependency'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `require'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:360:in `require_or_load'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:494:in `load_missing_constant'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:184:in `const_missing'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/inflector/methods.rb:263:in `const_get'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/inflector/methods.rb:263:in `block in constantize'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/inflector/methods.rb:259:in `each'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/inflector/methods.rb:259:in `inject'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/inflector/methods.rb:259:in `constantize'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/inflector/methods.rb:304:in `safe_constantize'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:572:in `safe_get'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:603:in `safe_constantize'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/inheritance.rb:154:in `block in compute_type'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/inheritance.rb:153:in `each'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/inheritance.rb:153:in `compute_type'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/reflection.rb:295:in `compute_class'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/reflection.rb:291:in `klass'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/associations/association.rb:118:in `klass'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/associations/collection_association.rb:41:in `reader'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/associations/builder/association.rb:115:in `versions'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/paper_trail-5.2.2/lib/paper_trail/record_trail.rb:447:in `public_send'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/paper_trail-5.2.2/lib/paper_trail/record_trail.rb:447:in `versions'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/paper_trail-5.2.2/lib/paper_trail/record_trail.rb:45:in `clear_rolled_back_versions'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/paper_trail-5.2.2/lib/paper_trail/model_config.rb:183:in `block in setup_transaction_callbacks'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:446:in `instance_exec'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:446:in `block in make_lambda'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:263:in `block in simple'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:506:in `block in call'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:506:in `each'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:506:in `call'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:778:in `_run_rollback_callbacks'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:322:in `rolledback!'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/transaction.rb:69:in `rollback_records'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/transaction.rb:120:in `rollback'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/transaction.rb:179:in `rollback_transaction'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/transaction.rb:186:in `rescue in within_new_transaction'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/transaction.rb:201:in `within_new_transaction'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/test_after_commit-1.0.0/lib/test_after_commit/database_statements.rb:5:in `transaction'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:220:in `transaction'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:291:in `save!'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/factory_girl-4.7.0/lib/factory_girl/configuration.rb:18:in `block in initialize'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/factory_girl-4.7.0/lib/factory_girl/evaluation.rb:15:in `create'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/factory_girl-4.7.0/lib/factory_girl/strategy/create.rb:12:in `block in result'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/factory_girl-4.7.0/lib/factory_girl/strategy/create.rb:9:in `tap'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/factory_girl-4.7.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/factory_girl-4.7.0/lib/factory_girl/factory.rb:42:in `run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/factory_girl-4.7.0/lib/factory_girl/factory_runner.rb:29:in `block in run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb:166:in `instrument'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/factory_girl-4.7.0/lib/factory_girl/factory_runner.rb:28:in `run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/factory_girl-4.7.0/lib/factory_girl/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
# ./my_spec.rb:8:in `block (2 levels) in <top (required)>'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:295:in `block (2 levels) in let'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:157:in `block (3 levels) in fetch_or_store'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:157:in `fetch'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:157:in `block (2 levels) in fetch_or_store'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-support-3.5.0/lib/rspec/support/reentrant_mutex.rb:23:in `synchronize'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:156:in `block in fetch_or_store'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:155:in `fetch'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:155:in `fetch_or_store'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:295:in `block in let'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:354:in `block in let!'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:350:in `run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:507:in `block in run_owned_hooks_for'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:506:in `each'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:506:in `run_owned_hooks_for'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:593:in `block in run_example_hooks_for'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:592:in `reverse_each'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:592:in `run_example_hooks_for'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:462:in `run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:490:in `run_before_example'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:253:in `block in run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:496:in `block in with_around_and_singleton_context_hooks'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:453:in `block in with_around_example_hooks'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:464:in `block in run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:604:in `block in run_around_example_hooks_for'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-rails-3.5.2/lib/rspec/rails/adapters.rb:127:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:375:in `execute_with'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:606:in `block (2 levels) in run_around_example_hooks_for'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
# ./spec/rails_helper.rb:460:in `block (3 levels) in <top (required)>'
# ./spec/rails_helper.rb:460:in `block (2 levels) in <top (required)>'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:375:in `execute_with'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:606:in `block (2 levels) in run_around_example_hooks_for'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
# ./spec/rails_helper.rb:304:in `block (3 levels) in <top (required)>'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rails-observers-0.1.2/lib/rails/observers/active_model/observer_array.rb:128:in `block in set_enablement'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rails-observers-0.1.2/lib/rails/observers/active_model/observer_array.rb:112:in `transaction'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rails-observers-0.1.2/lib/rails/observers/active_model/observer_array.rb:126:in `set_enablement'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rails-observers-0.1.2/lib/rails/observers/active_model/observer_array.rb:41:in `disable'
# ./spec/rails_helper.rb:304:in `block (2 levels) in <top (required)>'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:375:in `execute_with'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:606:in `block (2 levels) in run_around_example_hooks_for'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
# ./spec/rails_helper.rb:300:in `block (3 levels) in <top (required)>'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/generic/base.rb:16:in `cleaning'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/base.rb:98:in `cleaning'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/configuration.rb:86:in `block (2 levels) in cleaning'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/database_cleaner-1.5.3/lib/database_cleaner/configuration.rb:87:in `cleaning'
# ./spec/rails_helper.rb:300:in `block (2 levels) in <top (required)>'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:375:in `execute_with'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:606:in `block (2 levels) in run_around_example_hooks_for'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/failure_aggregator.rb:10:in `block in aggregate'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-support-3.5.0/lib/rspec/support.rb:103:in `with_failure_notifier'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.5.0/lib/rspec/expectations/failure_aggregator.rb:8:in `aggregate'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers.rb:313:in `aggregate_failures'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1972:in `block in define_built_in_hooks'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:375:in `execute_with'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:606:in `block (2 levels) in run_around_example_hooks_for'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:338:in `call'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:607:in `run_around_example_hooks_for'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:464:in `run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:453:in `with_around_example_hooks'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:496:in `with_around_and_singleton_context_hooks'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:251:in `run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:627:in `block in run_examples'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:623:in `map'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:623:in `run_examples'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:589:in `run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:590:in `block in run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:590:in `map'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:590:in `run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:113:in `block (3 levels) in run_specs'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:113:in `map'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:113:in `block (2 levels) in run_specs'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1835:in `with_suite_hooks'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:112:in `block in run_specs'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:77:in `report'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:111:in `run_specs'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:87:in `run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
# /usr/local/opt/rbenv/versions/2.3.1/bin/rspec:23:in `load'
# /usr/local/opt/rbenv/versions/2.3.1/bin/rspec:23:in `<top (required)>'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:74:in `load'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:27:in `run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli.rb:332:in `exec'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli.rb:20:in `dispatch'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli.rb:11:in `start'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/exe/bundle:34:in `block in <top (required)>'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors'
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/exe/bundle:26:in `<top (required)>'
# /usr/local/opt/rbenv/versions/2.3.1/bin/bundle:23:in `load'
# /usr/local/opt/rbenv/versions/2.3.1/bin/bundle:23:in `<main>'
# ------------------
# --- Caused by: ---
# ActiveSupport::Concern::MultipleIncludedBlocks:
# Cannot define multiple 'included' blocks for a Concern
# /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/concern.rb:126:in `included'
As you see I have installed also rbenv, that has symlink /usr/local/opt/rbenv
pointing to /usr/local/Cellar/rbenv
. So you see the both folders in the backtrace. May be it can be an issue?
Have you managed to reproduce it in a minimal project? I'd love to dig this.
Yes, you can download it here.
Just run bundle install
, rake db:create db:migrate
and rspec
. It should produce the backtrace.
thanks!
@casperisfine are you using any ruby manager (rbenv
, rvm
or other)? I could produce it with rbenv
fyi.
I'm using chruby. So that might be it. I'll try to find a testing ground with rbenv.
Same thing from my personal laptop with rbenv:
byroot@MacBook-Pro:check:$ rbenv -v
rbenv 1.0.0
byroot@MacBook-Pro:check:$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
byroot@MacBook-Pro:check:$ rspec
..
Finished in 0.03268 seconds (files took 1.39 seconds to load)
2 examples, 0 failures
Ok, guys, finally I figured out what the problem. It actually can depend on the way how rbenv
is installed. I don't know how it's installed in your system, but in my system I've installed it through brew
. What means that I have the following situation:
$ ls -l $(rbenv root)
lrwxr-xr-x 1 ka8725 admin 21 Dec 7 14:16 /usr/local/opt/rbenv -> ../Cellar/rbenv/1.1.0
Essential information here is that rbenv
home folder is a symlinked folder. Generally, when I call require 'somegem'
it add the gem's lib
path to $LOAD_PATH
using the symlinked folder name version (...
- truncated output, as it's not significant):
$ irb --simple-prompt
>> puts $LOAD_PATH
...
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/2.3.0
...
=> nil
>> require 'ap'
=> true
>> puts $LOAD_PATH
...
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/awesome_print-1.7.0/lib
...
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/2.3.0
...
=> nil
Then comes the most interesting part, described what is going on with the Rails application when I put this code in the application.rb
:
initializer :regenerate_require_cache, before: :load_environment_config do
Bootscale.regenerate
end
When I run rspec
command the Bootscale.regenerate
is called twice: the first call from require 'bootscale/setup'
and the second one from the initializer.
On the first call of regenerating paths I have the following $LOAD_PATH
(truncated also):
...
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/paper_trail-6.0.1/lib
...
On the second call:
...
/usr/local/Cellar/rbenv/1.1.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/paper_trail-6.0.1/lib
/usr/local/Cellar/rbenv/1.1.0/versions/2.3.1/lib/ruby/gems/2.3.0/gems/paper_trail-6.0.1/lib/paper_trail/frameworks
...
/usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/paper_trail-6.0.1/lib
...
What means that the paper_trail
gem was loaded but now it points also to the original folder additionally to the symlinked one (you can observe this issue in the tmp/bootstrap
folder in the project provided below. Also, it was already loaded entirely with the bundler help. It means that when we call require 'paper_trail/version_concern'
second time (and we actually do this) it will try to load the same file again. But there we have this ActiveSupport's included
block that can't be called twice and it leads to the exception.
Ruby doesn't understand that the file from the symlinked folder is the same as the original one. proof.
Currently everything works fine if I delete this code from the app:
initializer :regenerate_require_cache, before: :load_environment_config do
Bootscale.regenerate
end
As I understand, it slows down now application loading a little bit, but at least it works 😄 . I think this , it worth to optimize this thing somehow. For example, we could use the previous cache results to not rewrite paths for already loaded gems because their path is changed for some reason (symlink or whatever). What do you think?
Actually, I've profiled our application start and can conclude that this piece of code doesn't speed up loading at all. Does it really work? 😄
Actually, I've profiled our application start and can conclude that this piece of code doesn't speed up loading at all. Does it really work?
It's not for speedup, it's for correctness. When you require 'foo'
, MRI will look for foo.rb
in $LOAD_PATH.
With Bootscale enabled, require
will first look into bootscale's cache and in case of misses, will fallback to the original require.
So imagine the following case:
# /a/foo.rb and `/b/foo.rb` exists
$LOAD_PATH.unshift('/a')
Bootscale.setup
$LOAD_PATH.unshift('/b')
require 'foo.rb' # This would load `/a/foo.rb`
Bootscale.regenerate
require 'foo.rb' # This would load `/b/foo.rb`
So if you were not to call regenerate
after $LOAD_PATH
is modified, you could have the wrong file loaded.
But overall, the root cause of the problem is having the same physical directory, present twice in the $LOAD_PATH under 2 different names.
Definitely the root issue in the duplications. Do you have an idea how to fix it?
We might be able to overcome this by using File.realpath
. Let me do some tests.
@ka8725 can you try out this branch please: https://github.com/byroot/bootscale/tree/realpath
Having exception: https://gist.github.com/ka8725/aa61e695a41073ae59601464d7f9300b
Damn, that seem to only make the problem worse. Because you have a bunch of things required before bootscale kicks in, and they are recorded in $LOADED_FEATURES
via their symlinked name (or at least it's how I understand the failure).
I'll keep thinking about it, but so far I'm not sure how to handle this case. Your best bet for now would be to figure a way to get rid of those symlinks. What is weird is that I also installed rbenv via homebrew and I don't have this issue (however I haven't updated in a while, I still run 1.0.0)
I'm not sure that updating rbenv will change something, because I had the same issue with 1.0.0 as I remember.
Indeed. But my gems are installed in ~/.rbenv/versions
not /usr/local/
. I think that's the key difference, but I'm not sure what I or you did so that it differs.
This seems to be the reason: https://github.com/Homebrew/homebrew-core/blob/35ca0337298ae8faa69db877d9142b9cf4755ac4/Formula/rbenv.rb#L39-L47