I'm working with a local library (gem), let's call it B, inside my rails application A (Rails version 6.0.2.2)
In A's Gemfile, I require B via:
gem 'B', path: '../B'
When I do rails c with pry, I can access B and all its content correctly. However, when I make a local change to B and reopen rails c, the changes are not reflected.
If I quit the terminal (Mac OS) tab where I opened rails c and open another tab, suddenly all the changes that I made to B are reflected.
Does pry cache anything behind the scenes that's causing this flakiness?
Yes, your console is not reloaded automatically by Rails when you make changes.
This is to prevent triggering unexpected behavior in your console if you mix new objects with stale objects. However, you can reload your console manually by calling
reload!.Note, however, that all references to previous objects may be stale. E.g.:
As you can see by the
object_id, the class is not the same after a reload. Therefore theuserinstance will still point to the first version of your code, before reloading. Be sure to fetch a fresh user in that case.