markbates / configatron

A super cool, simple, and feature rich configuration system for Ruby apps.

Home Page:http://www.metabates.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug Report

FlyboyArt opened this issue · comments

I have a key set up like this in my config.yml file and in production mode, it gets read just fine however in development or test mode, Configatron crashes.

site:
version: 1.6.1
url: http://something.local/
domain: something.com

The crash spits out 'domain' as the key that is giving it trouble.

best, Art

Hey Art, I'll check it out. Can you give me a bit more information? Is there an exception being thrown? If so, what is it? What does your production version of the file look like? Or is it the same file? Have you tried configuring via Ruby instead of YAML? The Ruby way of configuration is the preferred way:

configatron.site.version = '1.6.1'
configatron.site.url = 'http://something.local/'
configatron.site.domain = 'something.com'

If you put that in an .rb file and require it should work. If you can answer those few questions, that would help a lot. Thanks.

Hi Mark,

The file is exactly the same and is read in by the same code in development or production mode. I haven't tried configuring via Ruby as the YAML file is a very convenient way of doing this. If YAML doesn't work then perhaps you should remove support for it. Here's the complete --trace output from rake (rake aborts and spits out 'domain' as the culprit:

** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:778: warning: instance variable @reload_plugins not initialized
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:778: warning: instance variable @reload_plugins not initialized
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:778: warning: instance variable @reload_plugins not initialized
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:778: warning: instance variable @reload_plugins not initialized
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:778: warning: instance variable @reload_plugins not initialized
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:778: warning: instance variable @reload_plugins not initialized
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:778: warning: instance variable @reload_plugins not initialized
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:778: warning: instance variable @reload_plugins not initialized
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:778: warning: instance variable @reload_plugins not initialized
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:778: warning: instance variable @reload_plugins not initialized
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:381: warning: *' interpreted as argument prefix /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:29: warning: method redefined; discarding old message /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/dirty.rb:40: warning:' interpreted as argument prefix
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:228: warning: _' interpreted as argument prefix /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/routing_ext.rb:2: warning: method redefined; discarding old to_param /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/recognition_optimisation.rb:55: warning: method redefined; discarding old recognize_path /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:306: warning: global variable $gems_rake_task' not initialized
/Library/Ruby/Gems/1.8/gems/ruby-openid-2.1.7/lib/openid/extras.rb:2: warning: method redefined; discarding old starts_with?
/Library/Ruby/Gems/1.8/gems/ruby-openid-2.1.7/lib/openid/extras.rb:7: warning: method redefined; discarding old ends_with?
/Library/Ruby/Gems/1.8/gems/chronic-0.2.3/lib/chronic/repeaters/repeater_month_name.rb:13: warning: useless use of > in void context
/Library/Ruby/Gems/1.8/gems/chronic-0.2.3/lib/chronic/repeaters/repeater_month_name.rb:19: warning: useless use of > in void context
/Library/Ruby/Gems/1.8/gems/chronic-0.2.3/lib/chronic/repeaters/repeater_month_name.rb:25: warning: useless use of < in void context
/Library/Ruby/Gems/1.8/gems/will_paginate-2.3.12/lib/will_paginate/finder.rb:141: warning: ambiguous first argument; put parentheses or even spaces
/Library/Ruby/Gems/1.8/gems/will_paginate-2.3.12/lib/will_paginate/finder.rb:209: warning:_' interpreted as argument prefix /Library/Ruby/Gems/1.8/gems/will_paginate-2.3.12/lib/will_paginate/view_helpers.rb:248: warning:
' interpreted as argument prefix
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:306: warning: global variable $gems_rake_task' not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:126: warning: instance variable @_locked not initialized rake aborted! domain /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:125:inmethod_missing'
/Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:282:in parse_options' /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:278:ineach'
/Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:278:in parse_options' /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:78:inconfigure_from_hash'
/Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:280:in parse_options' /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:278:ineach'
/Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:278:in parse_options' /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:78:inconfigure_from_hash'
/Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/store.rb:89:in configure_from_yaml' /Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/configatron.rb:15:insend'
/Library/Ruby/Gems/1.8/gems/configatron-2.5.1/lib/configatron/configatron.rb:15:in method_missing' /Users/artlap/rails/artandtracy/config/initializers/load_config.rb:2 /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:inload_without_new_constant_marking'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in load' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:innew_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in load' /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:622:inload_application_initializers'
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:621:in each' /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:621:inload_application_initializers'
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:176:in process' /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:insend'
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in run' /Users/artlap/rails/artandtracy/config/environment.rb:13 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:ingem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in require' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:inrequire'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in new_constants_in' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:inrequire'
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/tasks/misc.rake:4
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in call' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:inexecute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in each' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:inexecute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in invoke_with_call_chain' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:insynchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in invoke_with_call_chain' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:ininvoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in each' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:ininvoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in invoke_with_call_chain' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:insynchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in invoke_with_call_chain' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:ininvoke'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in invoke_task' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in each' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:intop_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in run' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in run' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31 /usr/bin/rake:19:inload'
/usr/bin/rake:19

The YAML support definitely works, although I would love to rip it out, but people seem to like using it for some reason. The problem doesn't appear to be with the 'domain' config, that's a red herring. The problem lies with Rails reloading classes, which it does in development mode, but not in production mode. You're getting a method missing error because Rails has thrown away every from the YAML file. Not sure why that's happening with the YAML implementation. It doesn't happen with the Ruby implementation. How are you loading your YAML file? Where abouts in your code are you doing it? I'm trying to figure out if that might have something to do with it.

I really encourage you to try the Ruby configuration. I think you'll much prefer it over the YAML, it's a lot nicer to use, and offers more features. All you need to do is:

ruby script/generate configatron

That will give you some handy .rb files in config/configatron where you can set up all your configurations. It'll also create the initializer file for you. It will then handle selecting the right files for the right Rails environment, etc... for you.

If you want to stick with the YAML, that's cool, but I'll need to you to answer those few questions I about how you're loading it to help me figure out what's going on. Thanks.

load in our constants, globals, etc.

configatron.configure_from_yaml("#{RAILS_ROOT}/config/config.yml")
is in my initializer directory...

I'll take a look at moving over to Ruby stuff but it's probably interesting for you to find out why this is happening.. Weird...

Configatron = great stuff, BTW

best, Art

Thanks. I do want to find out why it's doing this. It's definitely strange. It doesn't do it with the Ruby config style, which is what seems bizarre to me. I'm assuming Rails 2.3.5? I'm definitely going to check it out, just not sure when. :)

If you do convert over, you can do the following in the console:

configatron.inspect

and then you can copy and paste the output to the .rb files and you should be good to go. The .inspect method gives you a valid ruby code for configuration.

Yup, Rails 2.3.5 and I'm working on converting over now to the 'Ruby way' of doing things...

Well, the problem exists in the ruby code as well. I have a simple statement:

configatron.site.domain = "http://something.com"

and when I run a migration in development mode, rake reports the error 'domain'. when I run it in production mode, it works fine.

Back to square one...