rails console不起作用

时间:2011-01-08 19:20:01

标签: ruby-on-rails ruby windows console

我在Windows Vista上使用rails 3.0.3版和ruby版本1.9.2p136(2010-12-15)。脚本控制台给出了以下错误:

加载开发环境(Rails 3.0.3) C:/privat/Ruby192/lib/ruby/site_ruby/1.9.1/rbreadline.rb:2116:in block in _rl_read_init_file': invalid byte sequence in UTF 8 (ArgumentError) from C:/privat/Ruby192/lib/ruby/site_ruby/1.9.1/rbreadline.rb:2114:in each_line'         来自C:/privat/Ruby192/lib/ruby/site_ruby/1.9.1/rbreadline.rb:2114:in _rl_read_init_file' from C:/privat/Ruby192/lib/ruby/site_ruby/1.9.1/rbreadline.rb:2080:in rl_read_init_file'         来自C:/privat/Ruby192/lib/ruby/site_ruby/1.9.1/rbreadline.rb:2500:in readline_initialize_everything' from C:/privat/Ruby192/lib/ruby/site_ruby/1.9.1/rbreadline.rb:3726:in rl_initialize'         来自C:/privat/Ruby192/lib/ruby/site_ruby/1.9.1/rbreadline.rb:4720:in readline' from C:/privat/Ruby192/lib/ruby/site_ruby/1.9.1/readline.rb:40:in readline'         来自C:/privat/Ruby192/lib/ruby/1.9.1/irb/input-method.rb:115:在gets' from C:/privat/Ruby192/lib/ruby/1.9.1/irb.rb:139:in块(eval_input'中的2个级别)         来自C:/privat/Ruby192/lib/ruby/1.9.1/irb.rb:273:在eval_input中的signal_status' from C:/privat/Ruby192/lib/ruby/1.9.1/irb.rb:138:in块中         来自C:/privat/Ruby192/lib/ruby/1.9.1/irb/ruby-lex.rb:188:in call' from C:/privat/Ruby192/lib/ruby/1.9.1/irb/ruby-lex.rb:188:in buf_input'         来自C:/privat/Ruby192/lib/ruby/1.9.1/irb/ruby-lex.rb:103:in getc' from C:/privat/Ruby192/lib/ruby/1.9.1/irb/slex.rb:205:in match_io'         来自C:/privat/Ruby192/lib/ruby/1.9.1/irb/slex.rb:75:in match' from C:/privat/Ruby192/lib/ruby/1.9.1/irb/ruby-lex.rb:286:in token'         来自C:/privat/Ruby192/lib/ruby/1.9.1/irb/ruby-lex.rb:262:in lex' from C:/privat/Ruby192/lib/ruby/1.9.1/irb/ruby-lex.rb:233:in block(2个级别)in each_top_level_statement'         来自C:/privat/Ruby192/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in loop' from C:/privat/Ruby192/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in block in each_top_level_statement'         来自C:/privat/Ruby192/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in catch' from C:/privat/Ruby192/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in each_top_level_statement'         来自C:/privat/Ruby192/lib/ruby/1.9.1/irb.rb:155:在eval_input' from C:/privat/Ruby192/lib/ruby/1.9.1/irb.rb:70:in块中开始'         来自C:/privat/Ruby192/lib/ruby/1.9.1/irb.rb:69:in catch' from C:/privat/Ruby192/lib/ruby/1.9.1/irb.rb:69:in start'         来自C:/privat/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in start' from C:/privat/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in start'         来自C:/privat/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:23:in <top (required)>' from script/rails:6:in require'         来自script / rails:6:in''

我该怎么办?

3 个答案:

答案 0 :(得分:0)

问题是Ruby1.9.2有一些编码问题......你必须检查你的db驱动程序是否没有给出错误..你的服务器是否运行?我建议你使用Ruby187

答案 1 :(得分:0)

我遇到了同样的问题。我花了好几个小时试图修复它,重建ruby等等......对于任何设置LANG =它都失败了。

最后我在代码中发现它是在加载init文件期间,即〜/ .inputrc。

问题计算机中我的$ HOME没有〜/ .inputrc ...我试图创建一个空的...并且......工作了!

请尝试touch ~/.inputrc

答案 2 :(得分:0)

我刚刚遇到了与rails 4.1.1相同的问题,结果发现我的~/.inputrc文件是使用ISO-8859-1编码编码的。将文件转换为UTF-8后,一切正常:

$ iconv --from-code=ISO-8859-1 --to-code=UTF-8 ~/.inputrc >out
$ mv out ~/.inputrc

要检查inputrc文件的编码格式,请使用:

$ file --mime-encoding ~/.inputrc