Skip to content

Instantly share code, notes, and snippets.

@singularperturbation
Created January 5, 2015 22:13
Show Gist options
  • Save singularperturbation/ec150255a8be199f8e80 to your computer and use it in GitHub Desktop.
Save singularperturbation/ec150255a8be199f8e80 to your computer and use it in GitHub Desktop.
Pry output for debugging safe_yaml Psych::Nodes issues (https://github.com/dtao/safe_yaml/issues/72)
[1] pry(SafeYAML::PsychResolver)> show-source -a Psych
Found 2 candidates for `Psych` definition:
Candidate 1/2: /home/singularperturbation/.rbenv/versions/2.2.0/lib/ruby/2.2.0/psych/syntax_error.rb @ line 3:
Number of lines: 19
module Psych
class SyntaxError < Psych::Exception
attr_reader :file, :line, :column, :offset, :problem, :context
def initialize file, line, col, offset, problem, context
err = [problem, context].compact.join ' '
filename = file || '<unknown>'
message = "(%s): %s at line %d column %d" % [filename, err, line, col]
@file = file
@line = line
@column = col
@offset = offset
@problem = problem
@context = context
super(message)
end
end
end
Candidate 2/2: /home/singularperturbation/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/psych-2.0.8/lib/psych/exception.rb @ line 1:
Number of lines: 13
module Psych
class Exception < RuntimeError
end
class BadAlias < Exception
end
class DisallowedClass < Exception
def initialize klass_name
super "Tried to load unspecified class: #{klass_name}"
end
end
end
[2] pry(SafeYAML::PsychResolver)> show-source -a Psych::Nodes
Error: Couldn't locate a definition for Psych::Nodes!
[3] pry(SafeYAML::PsychResolver)>
@singularperturbation
Copy link
Author

This was after putting binding.pry in psych_resolver.rb, and psych was included in psych_handler.rb, which was loaded before. If I start irb/pry and manually do require 'psych' in the REPL, I can see Psych::Nodes just fine. I wasn't able to tell how/where Psych was being overridden, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment