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

[BUG] Loading RB files with Pathname in load_path raises TypeError #700

Closed
stevegeek opened this issue Sep 3, 2024 · 0 comments · Fixed by #701
Closed

[BUG] Loading RB files with Pathname in load_path raises TypeError #700

stevegeek opened this issue Sep 3, 2024 · 0 comments · Fixed by #701

Comments

@stevegeek
Copy link
Contributor

What I tried to do

Set I18n.load_path to Pathname instances rather than strings. This works for .yml, but for .rb files it raises.

This came up cause I allowed Rubocop to auto correct a configuration from

config.i18n.load_path += Dir[Rails.root.join("config/locales/**/*.{rb,yml}")]

to

config.i18n.load_path += Rails.root.glob("config/locales/**/*.{rb,yml}")

where glob returns Pathnames

What I expected to happen

It to not raise. It raises cause the 3rd argument to eval() should be a string to the file path

What actually happened

`eval': no implicit conversion of Pathname into String (TypeError)

translations = eval(IO.read(filename), binding, filename)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Versions of i18n, rails, and anything else you think is necessary

Rails 7.2,
I18n 1.14.5

PR with fix coming soon.

Thanks!

@stevegeek stevegeek changed the title [BUG] Loading RB files with Pathname raises TypeError [BUG] Loading RB files with Pathname in load_path raises TypeError Sep 3, 2024
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

Successfully merging a pull request may close this issue.

1 participant