I installed ruby on Ubuntu for system-wide use. The .irbrc_history file is created in a system directory rather than the user's home directory. This causes an access error when the file is owned by someone else. Here's the error besides a bunch more that I think is irrelevant:
irb
/usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/irb/ext/save-history.rb:75:in `initialize': Permission denied @ rb_sysopen - /usr/local/rvm/rubies/ruby-2.4.1/.irbrc_history (Errno::EACCES)
Deleting the history file resolves the error.
I tried adding environment variables and history initialization code to what I think is the system .irbrc file, but to no avail.
What is the sequence of initialization files being executed that impact this history file? How can I change the location of the history file?
Create, or edit your ~/.irbrc file to include:
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 200
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
Source: How To Persist Rails or IRB Console Command History After Exit
Do you happen to use RVM?
rvm 1.29.3 (current stable) has a bug where IRB history gets saved in the RUBY_HOME instead of HOME.
https://github.com/rvm/rvm/issues/4158
Here's a fix:
rvm get head
rvm reinstall 2.4.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With