Closed shoffing closed 1 year ago
Changing our config to use Rails.root.join fixes the issue:
config.credentials.content_path = Rails.root.join("config/credentials/#{credentials_env}.yml.enc")
However, using Strings for config seems common, e.g. in this stackoverflow post: https://stackoverflow.com/a/69216001/1570142
So, this library should probably have support for this pattern.
Thanks for the report!
It seems that Rails supports both strings and pathnames implicitly, because it always uses Rails.root
to convert the path to a relative one: https://github.com/rails/rails/blob/e6af9f55e6140ea396f73dcb60882d18131686a7/railties/lib/rails/commands/credentials/credentials_command.rb#L66
this library should probably have support for this pattern.
Agree. Will provide a fix soon.
What did you do?
Installed the gem and attempted to run Rails.
What did you expect to happen?
Rails starts successfully.
What actually happened?
Our application defines its credentials like:
So
content_path
is a String.Your library is trying to treat
content_path
as a Pathname, and this is causing Rails to error on start:https://github.com/palkan/anyway_config/blob/master/lib/anyway/rails/loaders/credentials.rb#L56
Was there a change to credentials in some recent Rails version? How can I fix this?
Additional context
This gem was installed as a dependency of AnyCable.
Environment
Ruby Version:
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
Framework Version (Rails, whatever):
Rails 7.0.4.3
Anyway Config Version:
anyway_config (2.4.1)