pat / combustion

Simple, elegant testing for Rails Engines
MIT License
707 stars 51 forks source link

Combustion failing for me on CI with Rails 5.2.2.1: tmp/development_secret.txt #97

Closed jrochkind closed 5 years ago

jrochkind commented 5 years ago

Having trouble figuring this one out.

I am using combustion with appraisal, to test multiple Rails versions.

On my Travis CI test, the appraisal using (the recently released) Rails 5.2.2.1 is now failing, on Combustion.initialize! :all, with:

Errno::ENOENT:
  No such file or directory @ rb_sysopen - /home/travis/build/jrochkind/attr_json/spec/internal/tmp/development_secret.txt
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/railties-5.2.2.1/lib/rails/application.rb:597:in `binwrite'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/railties-5.2.2.1/lib/rails/application.rb:597:in `generate_development_secret'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/railties-5.2.2.1/lib/rails/application.rb:430:in `secret_key_base'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/railties-5.2.2.1/lib/rails/application.rb:176:in `key_generator'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/globalid-0.4.2/lib/global_id/railtie.rb:28:in `block (2 levels) in <class:Railtie>'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:51:in `each'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.2.1/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/railties-5.2.2.1/lib/rails/application/finisher.rb:75:in `block in <module:Finisher>'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/railties-5.2.2.1/lib/rails/initializable.rb:32:in `instance_exec'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/railties-5.2.2.1/lib/rails/initializable.rb:32:in `run'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/railties-5.2.2.1/lib/rails/initializable.rb:61:in `block in run_initializers'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/railties-5.2.2.1/lib/rails/initializable.rb:60:in `run_initializers'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/railties-5.2.2.1/lib/rails/application.rb:361:in `initialize!'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/railties-5.2.2.1/lib/rails/railtie.rb:190:in `public_send'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/railties-5.2.2.1/lib/rails/railtie.rb:190:in `method_missing'
# ./gemfiles/vendor/bundle/ruby/2.4.0/gems/combustion-0.9.1/lib/combustion.rb:32:in `initialize!'

However, I can't reproduce this locally, the appraisal run works fine locally, with same rails version.

Working on trying to reproduce locally. But any ideas?

(In general, I'm starting to wonder if the combustion approach is actually giving me less trouble than the Rails standard full internal dummy app approach!)

jrochkind commented 5 years ago

OK, some more info! And it's looking good for combustion. :)

  1. I still can't reproduce this locally, it only fails on travis. Not sure why.

  2. However, i got the same error on a different project that does not use combustion, testing under rails 5.2.2.1. So it does not appear to be combustion's fault. It could be some kind of bug in 5.2.2.1. The failure is definitely related to this security patch in 5.2.2.1

  3. In my combustion-using app, I had previously had this:

     Combustion.initialize! :all do
         if "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}" == "5.2"
           config.secret_key_base = config.secret_token
           config.secret_token = nil
         end
     end

    I'm not sure why I did that, I didn't leave myself a note, but I must have previously thought it was necessary to get things to work on Rails 5.2

    However, it's what triggered the problem.

    If I change that to instead:

    config.secret_key_base = SecureRandom.hex(64) 
    config.secret_token = SecureRandom.hex(64) 

    Then my tests pass on travis again for Rails 5.2.2.1.

    If I also just remove that block entirely, and do nothing special in my local setup for Rails 5.2, then tests also pass again on Rails 5.2.2.1.

So I don't entirely understand what's going on, but things look good for combustion. And I still need to figure out how to fix the same problem in my non-combustion-using app. :)

jrochkind commented 5 years ago

Filed with Rails https://github.com/rails/rails/issues/35611

I don't think it's a combustion issue at all, and I think in fact the latest version of combustion protects you from the problem, so!

I won't close this just so you see it, but I think it can be closed. :)

pat commented 5 years ago

Appreciate all the details, and very happy to see it's already fixed in Rails 👍 Great detective work!