envkey icon indicating copy to clipboard operation
envkey copied to clipboard

Environment variable not removed from Rails (with Spring preloader) when renamed in EnvKey

Open ndbroadbent opened this issue 3 years ago • 1 comments

Hello, I just noticed a minor issue during development, but it could cause confusion when using an env var as a feature flag, etc.

Steps to reproduce:

  • Create an new variable in EnvKey under the dev environment, e.g. ENVKEY_WORKING=yes
  • Stop Spring if running (spring stop)
  • Start the Rails console
  • Check the var: puts ENV['ENVKEY_WORKING'] # => yes
  • Rename the variable in Envkey to ENVKEY_RUNNING
  • Restart the Rails console (with Spring)
  • Check the new var: puts ENV['ENVKEY_RUNNING'] # => yes
  • Check the old var: puts ENV['ENVKEY_WORKING'] # => yes

I would expect that the old ENVKEY_WORKING var would be removed. I can see how that would be tricky with the Spring preloader, but maybe you could store a list of variables that were set, and then compare that against the new list when the Rails process restarts, and remove any deleted ones from ENV.

Just a small issue but thought I should mention it! Cheers!

ndbroadbent avatar May 16 '22 01:05 ndbroadbent

Thanks @ndbroadbent will have a look at this!

danenania avatar May 16 '22 17:05 danenania