我遇到了这个问题几个小时。我无法在Windows中使用Railsinstaller环境运行rails c
。
我尝试了ruby 1.9.3
和ruby 2.0.0
。
当我rails new console_test; cd console_test; rails c
时,这是我得到的错误。
$ rails c
Loading development environment (Rails 4.0.2)
Switch to inspect mode.
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rb-readline-0.5.1/lib/rbreadline.rb:6083:in `delete': invalid byte sequence in UTF-8 (ArgumentError)
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rb-readline-0.5.1/lib/rbreadline.rb:6083:in `alloc_history_entry'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rb-readline-0.5.1/lib/rbreadline.rb:6116:in `add_history'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rb-readline-0.5.1/lib/readline.rb:368:in `<<'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/irb/ext/save-history.rb:91:in `block (2 levels) in load_history'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/irb/ext/save-history.rb:91:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/irb/ext/save-history.rb:91:in `block in load_history'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/irb/ext/save-history.rb:90:in `open'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/irb/ext/save-history.rb:90:in `load_history'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/irb/ext/save-history.rb:80:in `extended'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/irb/ext/save-history.rb:21:in `extend'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/irb/ext/save-history.rb:21:in `init_save_history'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/irb/ext/save-history.rb:44:in `save_history='
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/irb/context.rb:91:in `initialize'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/irb.rb:429:in `new'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/irb.rb:429:in `initialize'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/irb.rb:385:in `new'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/irb.rb:385:in `start'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/commands/console.rb:90:in `start'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/commands/console.rb:9:in `start'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:62:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
我在gem 'rb-readline', '~> 0.5.1', require: false
中添加了Gemfile
,但它并没有解决问题。
我从here下载了readline5.dll
,并重命名readline.dll
并转到与ruby二进制文件相同的目录。但它也没有用。
我还能做些什么来解决这个问题?
修改的
我删除了C:\RailsInstaller\Ruby2.0.0
和~/.gem
,然后安装了新的Railsinstaller。
但仍有rb-readline
错误。
我还下载并安装了Rubyinstaller
和Devkit
。即使rb-readline
错误也没有消失。
答案 0 :(得分:1)
我终于找到了,这个错误的原因。
我有~/.irbrc
就是这样。
require 'irb/ext/save-history'
#History configuration
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
我只是删除了.irbrc
,然后我可以毫无问题地使用rails console
。
答案 1 :(得分:-1)
您是否尝试过运行此命令:
Tools | Run Rails Console...