From: Josh Cheek Date: 2011-06-14T18:32:13+09:00 Subject: A way to find out when a constant gets defined? --0016e64c1848e1eadb04a5a8b5c4 Content-Type: text/plain; charset=ISO-8859-1 Hi, I'd like to be able to find out when a constant gets defined. I think I have a gem that vendored Psych, so it doesn't get listed in my dependencies, but causes the most unusual and difficult to track bugs (because other things, like rake tasks that don't load the entire environment, don't get Psych loaded, and thus behave differently when doing things like serializing data). Here is my reasoning: # I do not even have psych installed (it isn't listed) $ gem list psych *** LOCAL GEMS *** # Psych is not a dependency (no output) $ cat Gemfile.lock | grep -i psych # When I load irb with my app, Psych is somehow defined $ bundle exec irb ruby-1.9.2-p180 :001 > Psych => Psych ruby-1.9.2-p180 :002 > exit # When I load irb without my app, Psych is not defined $ irb ruby-1.9.2-p180 :001 > Psych NameError: uninitialized constant Object::Psych from (irb):1 from /Users/josh/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `
' ruby-1.9.2-p180 :002 > exit # For each file in my dir, exempting files in ./git, list the lines matching /psych/i # prints nothing, so Psych is not coming from my code. $ find . -name \* | ruby -ne 'puts $_ unless /^\.\/\.git/' | xargs grep -i psych I don't really know what to do, I tried `$ bundle package` and then untarring and gunzipping all the gems, and then grepping them for it, but didn't find anything. I can't figure out where this is coming from, so I'd like to be able to monitor the constant Psych to find out when it gets set. --0016e64c1848e1eadb04a5a8b5c4--