Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to exclude environments in Rails configuration file #79

Closed
jtuttle opened this issue May 7, 2021 · 2 comments
Closed

Unable to exclude environments in Rails configuration file #79

jtuttle opened this issue May 7, 2021 · 2 comments
Assignees

Comments

@jtuttle
Copy link
Contributor

jtuttle commented May 7, 2021

What did you do?

The README says you can't mix-and-match environment and non-environment values in the config file but it seems like I should be able to have one or the other.

In a Rails app, I tried to use a YAML configuration file without specifying any environments:

my_config.rb

class MyConfig < Anyway::Config
  attr_config :foo
end

my.yml

foo: bar

What did you expect to happen?

I expected MyConfig to read the value of foo as "bar".

What actually happened?

The MyConfig object is unable to read the value of foo from the YAML file:

[1] pry(main)> require_relative './lib/config/my_config.rb'
=> true
[2] pry(main)> MyConfig.new.foo
=> nil

Additional context

I'm able to load the value just fine if I include the Rails env in the config file, so I know it's not a mistake setting up paths or anything like that. If I change the config file as follows it works:

my.yml

development:
  foo: bar
[1] pry(main)> require_relative './lib/conjur/my_config.rb'
=> true
[2] pry(main)> MyConfig.new.foo
=> "bar"

but for this particular use case I don't want to have to specify environments in the config file.

Environment

Ruby Version: Ruby 2.5.8p224

Framework Version (Rails, whatever): Rails 5.2.6

Anyway Config Version: 2.1.0

@jtuttle
Copy link
Contributor Author

jtuttle commented May 7, 2021

Fortunately, I was able to fix this by setting config.anyway_config.future.unwrap_known_environments = true in config/application.rb. However, the README makes it sound like this setting is just supposed to allow you to mix-and-match env with non-env rather than enabling files that are completely non-env so I think there may still be a bug here. Going to leave this open for now.

@palkan
Copy link
Owner

palkan commented May 7, 2021

Thanks! Updated the Readme verbiage a bit.

@palkan palkan closed this as completed May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants