Pinpointing Unwanted Ruby Requires
Sometimes you need to find out exactly where a piece of Ruby code is being pulled in.
For instance, ActiveSupport turned up in an API and started breaking date handling and JSON serialization. While git bisect could locate the introducing commit, a more direct tool exists.
Place this snippet before any require calls to track every require event:
set_trace_func watches for :require events and evaluates the binding to inspect local variables. It logs each call and reports the moment a specific constant appears.
Using this approach, the offending source turned out to be require 'mail'.



