From: Josh Cheek Date: 2011-06-14T19:35:34+09:00 Subject: Re: A way to find out when a constant gets defined? --0016e644c7306e7f2004a5a998d7 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Jun 14, 2011 at 4:53 AM, Robert Klemme wrote: > Use set_trace_func lambda {|*a| p a} before the first require and try > to see whether you can find out from there psych code is loaded. > > This worked. I figured out that it must be coming from Bundler itself. Running set_trace_func against `require "bundler"` finds this: require 'pp' set_trace_func lambda { |event, filename, target_line, id, bnd, classname| next unless event == 'class' next unless File.exist? filename crnt_line = (1..1/0.0).each File.foreach filename do |line| next unless crnt_line.next == target_line && line =~ /psych/i puts "IN FILE #{filename.inspect}" puts "ON LINE #{target_line}" puts "THE LINE: #{line.inspect}" begin raise 'gettin the backtrace' rescue pp $!.backtrace end puts '-' * 100 end } require 'bundler' # >> IN FILE "/Users/josh/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/yaml.rb" # >> ON LINE 39 # >> THE LINE: "module Psych\n" # >> ["-:13:in `block (2 levels) in
'", # >> "-:7:in `foreach'", # >> "-:7:in `block in
'", # >> "/Users/josh/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/yaml.rb:39:in `'", # >> "/Users/josh/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/yaml.rb:39:in `'", # >> "/Users/josh/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'", # >> "/Users/josh/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'", # >> "/Users/josh/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.pre.5/lib/bundler.rb:10:in `'", # >> ":33:in `require'", # >> ":33:in `rescue in require'", # >> ":29:in `require'", # >> "-:21:in `
'"] # >> ---------------------------------------------------------------------------------------------------- Looking at its source, it comes from requiring yaml, a quick test: $ ruby -e 'require "yaml"; p Psych' Psych So I guess thats where it comes from. My errors are intermittent (and omg is that frustrating), but if I can nail down a reproducible example of the problem, I'll post it. --0016e644c7306e7f2004a5a998d7--