简体   繁体   English

US-ASCII(ArgumentError)中的字节序列无效,没有任何帮助

[英]invalid byte sequence in US-ASCII (ArgumentError), nothing helps

I start having an error all of a sudden whenever I run rake db:create . 每当我运行rake db:create时,我都会突然发生错误。 The error is 错误是

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>'

I did 我做到了

me@ubuntu:~ export LANG="C.UTF-8"
me@ubuntu:~ export LC_ALL="C.UTF-8"

I got 我有

me@ubuntu:~ echo $LANG
en_US
me@ubuntu:~ echo $LC_ALL
en_US.UTF-8

try adding, as first line of the files touched by this task, the string: 尝试添加,作为此任务触及的文件的第一行,字符串:

#encoding: utf-8

These files may be all your custom initializers, your database.yml, etc 这些文件可能是您的所有自定义初始化程序,您的database.yml等

find . -name *.rb | xargs grep -P "[\x80-\xFF]" -l | xargs sed "1i # encoding: utf-8" -i

try this to fix every .rb file 试试这个来修复每个.rb文件

UPD: tested on ubuntu only. UPD:仅在ubuntu上测试。

If your name contains a non-US ASCII character (mine has a "Ö" in it), you get lost using Bitnami Redmine stack, since they record that name without any changes to the setup.rb file. 如果你的名字包含一个非美国ASCII字符(我的中有一个“Ö”),那么使用Bitnami Redmine堆栈就会丢失,因为它们会记录该名称,而不会对setup.rb文件进行任何更改。 It causes this exact error notification 'invalid byte sequence in US-ASCII (ArgumentError)'. 它会导致此精确错误通知'US-ASCII(ArgumentError)'中的无效字节序列。 As soon as I renamed myself in that file to "oe" everything worked fine! 一旦我将该文件重命名为“oe”,一切正常! (after rake db:migrate) (在rake db:migrate之后)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MembersController中的ArgumentError#登录US-ASCII中的无效字节序列 - ArgumentError in MembersController#login invalid byte sequence in US-ASCII ArgumentError(US-ASCII中无效的字节序列):在ruby升级1.9.3中 - ArgumentError (invalid byte sequence in US-ASCII): in ruby upgrade 1.9.3 bundle install error“US-ASCII(ArgumentError)中的无效字节序列” - bundle install error “invalid byte sequence in US-ASCII (ArgumentError)” Heroku-US-ASCII中的无效字节序列(ArgumentError) - Heroku - invalid byte sequence in US-ASCII (ArgumentError) US-ASCII whith数组中的无效字节序列 - invalid byte sequence in US-ASCII whith array rake任务因US-ASCII中的无效字节序列而失败 - rake tasks fail with invalid byte sequence in US-ASCII Rails:运行 rake db:seed 时 US-ASCII 中的字节序列无效(参数错误) - Rails: Invalid byte sequence in US-ASCII (Argument Error) when I run rake db:seed 将Ruby升级到1.9.2后,Rails查看错误“US-ASCII中的无效字节序列”错误 - Rails view error “invalid byte sequence in US-ASCII” error after upgrading Ruby to 1.9.2 US-ASCII中的无效字节序列(Ruby 1.9 + rails 2.3.8 + mongodb + mongo_mapper) - invalid byte sequence in US-ASCII (Ruby 1.9 + rails 2.3.8 + mongodb + mongo_mapper) RVM,Ruby 1.9.2,Rails 2.3.8,Passenger和“US-ASCII中的无效字节序列” - RVM, Ruby 1.9.2, Rails 2.3.8, Passenger and “invalid byte sequence in US-ASCII”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM