Watch for interaction between globalrc and local config files

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the vendors category.

Last Updated: 2021-05-16

(This seems Ruby specific, but it's not - hang on in there)

I wanted to delete a problematic command in pry (an interactive Ruby REPL console). Therefore in my ~/.pryrc I added this code.

dot_command = /\.(.*)/

I also wanted to ensure this configuration was available on my server for a particular Rails project, so I added a config/initializers/pry.rb within this project.

This caused me to observe the following error whenever I opened a pry session in this project (but not elsewhere):

ArgumentError: Cannot find a command: '(?-mix:\.(.*))'!

The issue was that the configuration code (being destructive) could not be run twice in a row without error.


The solution was to suppress the global rc file in this config/initializers/pry.rb file

Pry.config.should_load_rc = false