ruby on rails - Exception RuntimeError in Rack application object Missing `secret_token` and `secret_key even after adding the secret key -


while deploying rails app on aws intance got following error.i not able figure out problem. using nginx , passenger. searched internet still not found solution. following content of error log file.

app 10537 stdout: app 10537 stderr:  --> compiling passenger_native_support.so current ruby interpreter... app 10537 stderr: app 10537 stderr:      (set passenger_compile_native_support_binary=0 disable) app 10537 stderr: app 10537 stderr:  --> downloading precompiled passenger_native_support.so current ruby interpreter... app 10537 stderr: app 10537 stderr:      (set passenger_download_native_support_binary=0 disable) app 10537 stderr: app 10537 stderr:      not download https://oss-binaries.phusionpassenger.com/binaries/passenger/by_release/5.0.13/rubyext-ruby-2.2.0-x8$ app 10537 stderr:      trying next mirror... app 10537 stderr:      not download https://s3.amazonaws.com/phusion-passenger/binaries/passenger/by_release/5.0.13/rubyext-ruby-2.2.0-x$ app 10537 stderr:  --> continuing without passenger_native_support.so. app 10537 stderr: rails error: unable access log file. please ensure /usr/share/nginx/html/trans-info/log/production.log exists , is$ app 10560 stdout: app 10537 stderr: [ 2015-07-10 22:00:38.0639 10560/0x00000000e1da20(worker 1) utils.rb:85 ]: *** exception runtimeerror in rack application ob$ app 10537 stderr:       /home/ubuntu/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/application.rb:520:in `validate_secret_key_config$ app 10537 stderr:       /home/ubuntu/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/application.rb:246:in `env_config' app 10537 stderr:       /home/ubuntu/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/engine.rb:514:in `call' app 10537 stderr:       /home/ubuntu/.rvm/gems/ruby-2.2.0/gems/railties-4.2.0/lib/rails/application.rb:164:in `call' app 10537 stderr:       /usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:94:in `process_request' app 10537 stderr:       /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:149:in `accept_and_process_next_req$ app 10537 stderr:       /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop' app 10537 stderr:       /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:415:in `block (3 levels) in start_threads' app 10537 stderr:       /usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:111:in `block in create_thread_and_abort_on_exception' [ 2015-07-10 22:00:38.0641 10511/7fdb5a226700 age/cor/req/utils.cpp:95 ]: [client 1-1] sending 502 response: application did not send comple$ app 10567 stdout: app 10574 stdout: 

the problem regarding secret key guess. tried following things set secret key production environment. still doesn't solve problem.

export secret_key_base=<rake secret> ruby -e 'p env["secret_key_base"]' 

i fixed problem in rails 4.2.3 updating file inside yourapp/config/secrets.yml generated rake secret key

you see in file development , test environment line have random generated key :

development:   secret_key_base: 0d61219baac693241c55f0d5e32casdasdasdasdas3adc915d60f303bb55bfe0f9c7d3d7c77914ebba3924529b0f55fa2ddc2f861052d9b7bb25ea5d1asdasdasdasdas8d857ed2dc8df0cdccd3a  test:   secret_key_base: 12df598106f9f303d34c087aasdasdas85f7439b86e881788340c85e932aa14579661c0606b29ac9ff6438619e65b8ac0abd201e7asdasdasdsad2555d77d975a8c522032e8bfa956bb3  # not keep production secrets in repository, # instead read values environment. production:   secret_key_base: 5b2555128d5b97181d2a65aeasdasdasddd2cb4d7df37b49dd97de7ebb2305d56a1c649be86bff3fc48536543eead7091018e5casdasdasdasdasd5c563c6ca02771e1b5f99cbc35db886cd9 

and production had :

production: secret_key_base: <%= env["secret_key_base"] %>

so changed line rake secret command generated key

production:   secret_key_base: 5b2555128d5b97181d2a65aeasdasdasddd2cb4d7df37b49dd97de7ebb2305d56a1c649be86bff3fc48536543eead7091018e5casdasdasdasdasd5c563c6ca02771e1b5f99cbc35db886cd9 

Comments