I have Ruby 2.3.0p0 installed via rbenv, 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 rbenv, 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).
Looking at my .irb_history file, it appears that it is getting replaced, rather than appended, with the commands from the latest session. I can load up a 2.0.0 IRB session and scroll through those commands just fine.
I've tried the answers listed in rbenv irb history is not saving without success.
I also tried the selected answer in irb history not working.
I had to alter the selected answer to replace the #nitems method. This showed that lines were being read out from the history file, and pushed on to Readline::HISTORY
. However, examining Readline::HISTORY
shows nothing there.
I can sort of hack in history by adding previous lines from my .irb_history to the Readline history via Readline.readline
, and specifying add_hist=true. However, it is definitely not the proper way to add the previous commands to Readline.
I know I can switch over to something like pry, but I'd like to figure this out. Any suggestions on why the commands are not being added to Readline, and how to change that?
~/.rbenv/versions/2.3.0/lib/ruby/2.3.0/irb/ext/save-history.rb
is full of code which makes history work. I'd think if yours was blank, irb history wouldn't work with or without readline. – Ticktock