laserlemon / figaro

Simple Rails app configuration
MIT License
3.76k stars 288 forks source link

Why is _FIGARO_ being prepended to my ENV keys? #233

Closed TopOneOfTopOne closed 8 years ago

TopOneOfTopOne commented 8 years ago
#config/application.yml 
api_key: 1234

Looking at my ENV hash in rails console:

 "_FIGARO_api_key"=>"1234"

This is an issue since I cannot access api_key as usual i.e. ENV['api_key']

UPDATE: This seems to only occur on my windows OS but on my OSX i obtain both keys api_key and _FIGARO_api_key .

laserlemon commented 8 years ago

Silly question but have you tried to access it with ENV["api_key"]? Should work.

TopOneOfTopOne commented 8 years ago

Yes I have, it returns nil maybe I have done something wrong... EDIT: I mean for windows. For OSX ENV['api_key'] returns the correct value as intended

laserlemon commented 8 years ago

The _FIGARO_-prefixed key/value pair is set to keep track of which values were set by Figaro and which were already set by the system environment. This information is needed to determine which to override and which to leave alone if Figaro is loaded multiple times (as can happen).

Out of curiosity, does the presence of the additional key/value pairs cause any issue on OS X?

And on Windows, you still can't access ENV["api_key"]? If that's the case, could you try to clone Figaro on Windows and run the test suite? I don't currently test against Windows since I have no easy way to do it. Thank you!

laserlemon commented 8 years ago

Also, if you're using Spring, make sure to restart it after you make changes to your config file. Or stop using Spring. 😊

TopOneOfTopOne commented 8 years ago

No it does not cause any issues on OSX. Sure I will get on my windows computer and check again. But... Sorry to have bothered you, it is probably a problem on my end since I am a beginner. But I thank you your program really helps beginner programmers like me 😄

laserlemon commented 8 years ago

No bother at all! Hope I could help. I'll close the issue but feel free to comment again if you discover there is some bug. Thanks!

TopOneOfTopOne commented 8 years ago

I appreciate your kindness, and after further investigation it was my fault :disappointed:

laserlemon commented 8 years ago

Thanks for reporting back! Care to share what was going on, in case somebody else is struggling with the same issue?