IRB history not working with Ruby 2.5.1 on macosx

I have Ruby 2.5.1 installed via rvm, on OS X 10.11.4. Within an IRB session, history works fine. However, I cannot access IRB history across sessions.

I tried my system Ruby, 2.0.0p648, and history across IRB sessions works fine. I tried installing that same version of Ruby via rvm, and it also has working history.

I’ve compared the values of IRB.conf between a working and nonworking session, and nothing looks out of place (although, weirdly, irb/ext/save-history.rb is a blank file in both cases).

OS X’s command-line editing is based on the libedit library. OS X has a version of the readline library which is a wrapper around libedit, but it does not behave completely like GNU readline. irb history works in Ruby built with OS X’s wrapper up to Ruby 2.1, but Ruby 2.2 and later need to be built with GNU readline for irb history to work.

Using Homebrew with rbenv

brew install readline if it isn't installed already
rbenv uninstall 2.5.1
rbenv install 2.5.1

Using rvm

rvm pkg install readline
rvm reinstall all --force