rbenv irb history is not saving
Asked Answered
A

2

18

I install ruby via rbenv-installer.

When I use irb console, I can use history by pressing up and down on keyboard. And when I exited from console and start it again, I can't use prewious history. When I press up-arrow-button, nothing was happened.

When I used rvm this option was working. How can I switch on it in rbenv?

Accad answered 21/6, 2012 at 11:20 Comment(1)
See also #37848322 which discusses how ruby must be complied with readlineOstend
A
45

I found this way for solving my problem. In file ~/.irbrc write:

require 'irb/ext/save-history'
#History configuration
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"

Found in this question: irb history not working

Accad answered 21/6, 2012 at 11:27 Comment(4)
Adding just the IRB.conf[:SAVE_HISTORY] = 10000 line was sufficient to fix things for me.Sourdine
If this doesn't work, and you are on OS X, you may need to update your Readline library. See #37848322Demineralize
I had the same issue on OS X that @EvanPon described. I had to update my Readline library and reinstall Ruby via rbenv. See the post he linked for details.Discard
This doesn't work for me, in Ubuntu 14.04. I know that ~/.rbrc is being processed because I put a puts at the top. But it just doesn't make any difference. I have Readline installed - at least, I can do Readline in the console.Druse
K
13

Create ~/.irbrc if it does not exist, and add the following line to it:

IRB.conf[:SAVE_HISTORY] = 1000
Kortneykoruna answered 22/1, 2016 at 19:4 Comment(1)
Sufficient for me (ruby 2.2). History gets saved automatically to ~/.irb_historySkysail

© 2022 - 2024 — McMap. All rights reserved.