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

Loading config file with Ruby head #1408

Open
MSP-Greg opened this issue Oct 12, 2021 · 0 comments
Open

Loading config file with Ruby head #1408

MSP-Greg opened this issue Oct 12, 2021 · 0 comments

Comments

@MSP-Greg
Copy link
Contributor

Using Ruby head, the Psych gem raises errors when loading a config file, in the following code:

yard/lib/yard/config.rb

Lines 233 to 243 in 9865620

# Loads the YAML configuration file into memory
# @return [Hash] the contents of the YAML file from disk
# @see CONFIG_FILE
def self.read_config_file
if File.file?(CONFIG_FILE)
require 'yaml'
YAML.load_file(CONFIG_FILE)
else
{}
end
end

Replacing it with the following fixes the issue.

def self.read_config_file
  if File.file?(CONFIG_FILE)
    require 'yaml'
    if YAML.respond_to?(:safe_load_file)
      begin
        YAML.safe_load_file(CONFIG_FILE)
      rescue Psych::DisallowedClass
        YAML.safe_load_file(CONFIG_FILE, permitted_classes: [SymbolHash, Symbol])
      end
    else
      YAML.load_file(CONFIG_FILE)
    end
  else
    {}
  end
end

Steps to reproduce

My config file has the following, used it for a long time, not sure whether causes the error:

--- !ruby/hash-with-ivars:SymbolHash
elements:
  :stuff
ivars:
  :@symbolize_value: false

Environment details:

  • OS: Windows 10
  • Ruby version (ruby -v): ruby 3.1.0dev (2021-10-12T08:12:01Z master 2143de251d) [x64-mingw32]
  • YARD version (yard -v): yard 0.9.26

Most of my YARD code runs under Windows, as I haven't converted it to Ubuntu. I do not think this issue is platform specific...

I have read the Contributing Guide.

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

1 participant