MacOS Ventura firewall repeatedly asks to accept incoming connections when reinstalling a Ruby version with rbenv

On my Intel iMac on macOS Ventura 13.4 I ran into this annoying issue when reinstalling the same version of Ruby (3.2.2 for example) with rbenv. When running rails test:system the firewall’s “Accept incoming connections” dialog would pop every time, no matter whether you Denied or Allowed the connection to go through previously, making testing quite painful.

I couldn’t find a working solution through googling, but ChatGPT was able to help. It’s as simple as:

sudo codesign --force --sign - $HOME/.rbenv/versions/3.2.2/bin/ruby

Simply find the ruby bin version you’re having problems with inside your .rbenv folder and instruct macOS to re-sign it. The expected output should be something like:

/Users/klevo/.rbenv/versions/3.2.2/bin/ruby: replacing existing signature

After that, you’ll need to confirm or deny the “Accept incoming connections” Firewall dialog when running something like system test suite, but afterwards the Firewall should remember your choice.

Lastly, this only seems to affect Intel Macs. At least for me, no such issue occurred when reinstalling ruby with rbenv on an ARM MacBook.

Thanks AI 🙂