Rails控制台不起作用。得到这个错误

时间:2019-11-04 08:01:43

标签: ruby-on-rails ruby

Traceback (most recent call last):
16: from /home/hman01/.rvm/rubies/ruby-2.5.0/bin/irb:11:in `<main>'
15: from /home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:381:in `start'
14: from /home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:381:in `new'
13: from /home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:410:in `initialize'
12: from /home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:410:in `new'
11: from /home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/context.rb:91:in `initialize'
10: from /home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/extend-command.rb:242:in `save_history='
 9: from /home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ext/save-history.rb:45:in `save_history='
 8: from /home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ext/save-history.rb:21:in `init_save_history'
 7: from /home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ext/save-history.rb:21:in `extend'
 6: from /home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ext/save-history.rb:65:in `extended'
 5: from /home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ext/save-history.rb:75:in `load_history'
 4: from /home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ext/save-history.rb:75:in `open'
 3: from /home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ext/save-history.rb:76:in `block in load_history'
 2: from /home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ext/save-history.rb:76:in `each'
 1: from /home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ext/save-history.rb:76:in `block (2 levels) in load_history'
/home/hman01/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ext/save-history.rb:76:in `<<': string contains null byte (ArgumentError)

2 个答案:

答案 0 :(得分:2)

save-history.rb:76处检查源代码,看来您的历史记录文件有问题。我会尝试删除IRB历史记录文件。根据{{​​3}},它可以在多个地方

如果您的HOME环境已设置:

rm ~/.irb_history

如果不是,则从工作目录:

rm .irb_history irb.history _irb_history '$irb_history`

答案 1 :(得分:0)

我已经修改了save-history.rb文件。

f.each {|l| HISTORY << l.gsub("\u0000", '').chomp}.

现在可以正常工作了。