This project is archived and is in readonly mode.
missing config.gem causes a strange error in rake tasks
-
Markús
I'm getting the same error in a fresh rails application using rails-edge. In this case I'm not declared anything, I created it and I ran script/generate (with any argument, all return the same), an then...
rails/actionpack/lib/action_controller/session/cookie_store.rb:163:in `ensure_session_key': A key is required to write a cookie containing the session data. Use config.action_controller.session = { :key => "_myapp_session", :secret => "some secret phrase" } in config/environment.rb (ArgumentError) from /Users/marcosariaspena/code/tests/test/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb:74:in `initialize' from /Users/marcosariaspena/code/tests/test/vendor/rails/actionpack/lib/action_controller/middleware_stack.rb:72:in `new'The environment apparently ignores session = {} declaration, both in initializer/session_store.rb or in environment.rb.
Some rake tasks returns this error too (such as "rake middleware")
-
Markús
- Assigned user set to josh
I've found something about this error:
This commit changes the way SessionStore is initialized, allowing custom settings in session store...
Well, the actual code is:
# actionpack/lib/action_controller/middlewares.rb - line 7 use lambda { ActionController::Base.session_store }, ActionController::Base.session_optionsThis, for some reason, it's not interpreted as expected and doesn't load ActionController::Base.sesion_store, whatever value it has, you must add :if => true at the end to force that load
# actionpack/lib/action_controller/middlewares.rb - line 7 use lambda { ActionController::Base.session_store }, ActionController::Base.session_options, :if => trueI'm trying to figure out in my local rails clone why is this happening
-
Markús
I've found another strange thing regarding this error
If you change this code
# actionpack/lib/action_controller/middleware_stack.rb - line 17 options = args.extract_options! if options.has_key?(:if) @conditional = options.delete(:if) else @conditional = true end args << options unless options.empty?For this one, which is practically the same (I'm going to annotate the differences), all works fine
# options = args.extract_options! always do a pop in args if args.last.is_a?(Hash) && args.last.has_key?(:if) @conditional = args.last.delete(:if) # only do a pop if the args.last remains empty after deleting the :if option args.pop if args.last.empty? else @conditional = true end # args << options unless options.empty? should retrieve the extracted options without the if, but this don't work, only if the pop is made when the args.last is an empty hashAs you can see, this 2 pieces of code are practically the same, but produces 2 different results. I think the eval() of actionpack/lib/action_controller/middlewares.rb file might be related with this behavior.
-
Markús
I created a patch with the previous comment code.
-
Markús
I don't think the whole ticket it's a duplicate, the error pointed by Akira Matsuda its still there.
I've updated my rails repo with the middleware fix by Sven Fuchs, and a fresh app works fine, but once you specify a config.gem which you have not installed yet, the error raise again
Rails::Initializer.run do |config| config.gem "aws-s3", :lib => "aws/s3" # Or any gem you had't installed yet # .. end"rake gems" fails with this message:
rake aborted! A key is required to write a cookie containing the session data. Use config.action_controller.session = { :key => "_myapp_session", :secret => "some secret phrase" } in config/environment.rb -
Jeff Kreeftmeijer
Automatic cleanup of spam.
