Ever get frustrated trying to search through code on GitHub? Or wish you could put a breakpoint in a gem so you could figure out what it was doing?
Don’t mess around with cloning the gem repo or monkey patching code in your own app. Use
bundle open instead.
In your shell, run the command:
bundle open GEM_NAME
bundler will open the source code for the exact version of the gem you’ve got installed in your editor. You can search the code inside your editor and even add breakpoints or make code changes locally to test out things.
bundle open command launches the editor that you’ve set via the
BUNDLER_EDITOR environment variables. You can set this to be
VS Code, or whatever tool you like to use.
If you’ve made changes to the local gems for debugging or experimental purposes, you can use the
bundle pristine command to restore your gems to their “original” state.
Bundler Docs: bundle open
Bundler Docs: bundle pristine