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

Ruby 3.1 compatibility #2

Closed
sphynx79 opened this issue Mar 28, 2022 · 3 comments
Closed

Ruby 3.1 compatibility #2

sphynx79 opened this issue Mar 28, 2022 · 3 comments

Comments

@sphynx79
Copy link

The new ruby 3.1 use as default gem psych 4.0.3, with this version there is problem to load alias, i receive this error message
Unknown alias: defaults
To fix the problem you can change your yaml_to_hash method in this way:

    # Internal: Parses a yml file that can optionally use ERB templating.
    def yaml_to_hash(file_name)
      return {} if (content = File.open(file_name).read).empty?
      if Psych::VERSION > '4.0'
        YAML.load(ERB.new(content).result, aliases: true).to_hash
      else
        YAML.load(ERB.new(content).result).to_hash
      end
    end

In this way it works with ruby 3.1 and keep backwards compatibility

@ElMassimo
Copy link
Owner

Hi Sphynx! @sphynx79

Thanks for reporting and providing a fix.

Happy to accept a PR if you would like to create one, or I can make one with your fix 😃

@sphynx79
Copy link
Author

Sorry i'am not able to create PR :(

Can you fix the code?

Thanks

@ElMassimo
Copy link
Owner

@sphynx79 Released a fix under better_settings-1.0.2, which now requires Ruby 3.1 or greater.

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