每当我运行rake db:create
时,我都会突然发生错误。错误是
rake aborted!
/home/me/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.4/lib/rake/trace_output.rb:16:in `block in trace_on': invalid byte sequence in US-ASCII (ArgumentError)
from /home/me/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.4/lib/rake/trace_output.rb:14:in `map'
from /home/me/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.4/lib/rake/trace_output.rb:14:in `trace_on'
from /home/me/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.4/lib/rake/application.rb:328:in `trace'
from /home/me/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.4/lib/rake/application.rb:183:in `display_error_message'
from /home/me/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.4/lib/rake/application.rb:169:in `rescue in standard_exception_handling'
from /home/me/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.4/lib/rake/application.rb:159:in `standard_exception_handling'
from /home/me/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
from /home/me/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.4/bin/rake:33:in `<top (required)>'
from /home/me/.rvm/gems/ruby-1.9.3-p392/bin/rake:23:in `load'
from /home/me/.rvm/gems/ruby-1.9.3-p392/bin/rake:23:in `<main>'
我做了
me@ubuntu:~ export LANG="C.UTF-8"
me@ubuntu:~ export LC_ALL="C.UTF-8"
我得到了
me@ubuntu:~ echo $LANG
en_US
me@ubuntu:~ echo $LC_ALL
en_US.UTF-8
答案 0 :(得分:11)
尝试添加字符串:
作为此任务触及的文件的第一行#encoding: utf-8
这些文件可能是您的所有自定义初始化程序,您的database.yml等
答案 1 :(得分:7)
find . -name *.rb | xargs grep -P "[\x80-\xFF]" -l | xargs sed "1i # encoding: utf-8" -i
尝试此操作来修复每个.rb文件
UPD:仅在ubuntu上测试。
答案 2 :(得分:0)
如果你的名字包含一个非美国ASCII字符(我的中有一个“Ö”),那么使用Bitnami Redmine堆栈就会丢失,因为它们会记录该名称,而不会对setup.rb文件进行任何更改。它会导致此精确错误通知'US-ASCII(ArgumentError)'中的无效字节序列。一旦我将该文件重命名为“oe”,一切正常! (在rake db:migrate之后)