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:
我在Ubuntu上安装了ruby以供全系统使用。irbrc_history文件是在系统目录中创建的,而不是用户的主目录。当文件被其他人拥有时,这会导致访问错误。除了很多我认为不相关的错误之外
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.
我尝试将环境变量和历史初始化代码添加到我认为的系统.irbrc文件中,但是没有效果。
What is the sequence of initialization files being executed that impact this history file? How can I change the location of the history file?
正在执行的初始化文件的顺序对这个历史文件有什么影响?如何更改历史文件的位置?
3 个解决方案
#1
6
Create, or edit your ~/.irbrc file to include:
创建或编辑您的~/。irbrc文件包括:
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
源代码:如何在退出后保存Rails或IRB控制台命令历史记录
#2
1
Do you happen to use RVM?
你会使用RVM吗?
rvm 1.29.3 (current stable) has a bug where IRB history gets saved in the RUBY_HOME
instead of HOME
.
rvm 1.29.3(当前的稳定)有一个bug, IRB的历史可以在RUBY_HOME而不是HOME保存。
https://github.com/rvm/rvm/issues/4158
https://github.com/rvm/rvm/issues/4158
Here's a fix:
这里有一个解决办法:
rvm get head
rvm reinstall 2.4.1
#3
0
Create the file in your home directory: touch ~/.irbrc_history
.
在主目录中创建文件:touch ~/.irbrc_history。
Or copy it from the system path to your home directory: cp /path/of/system/.irbrc_history ~/.irbrc_history
或从系统路径复制到您的主目录:cp /path/of/system/。irbrc_history ~ / .irbrc_history
Note that you should change /path/of/system/
to whatever you have on your system.
注意,您应该更改/path/of/system/到您的系统上的任何内容。
Once the file is in your home directory (given by ~
) then it will run when your user runs irb
一旦文件在您的主目录中(由~给出),那么当您的用户运行irb时它将运行
#1
6
Create, or edit your ~/.irbrc file to include:
创建或编辑您的~/。irbrc文件包括:
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
源代码:如何在退出后保存Rails或IRB控制台命令历史记录
#2
1
Do you happen to use RVM?
你会使用RVM吗?
rvm 1.29.3 (current stable) has a bug where IRB history gets saved in the RUBY_HOME
instead of HOME
.
rvm 1.29.3(当前的稳定)有一个bug, IRB的历史可以在RUBY_HOME而不是HOME保存。
https://github.com/rvm/rvm/issues/4158
https://github.com/rvm/rvm/issues/4158
Here's a fix:
这里有一个解决办法:
rvm get head
rvm reinstall 2.4.1
#3
0
Create the file in your home directory: touch ~/.irbrc_history
.
在主目录中创建文件:touch ~/.irbrc_history。
Or copy it from the system path to your home directory: cp /path/of/system/.irbrc_history ~/.irbrc_history
或从系统路径复制到您的主目录:cp /path/of/system/。irbrc_history ~ / .irbrc_history
Note that you should change /path/of/system/
to whatever you have on your system.
注意,您应该更改/path/of/system/到您的系统上的任何内容。
Once the file is in your home directory (given by ~
) then it will run when your user runs irb
一旦文件在您的主目录中(由~给出),那么当您的用户运行irb时它将运行