升级到 ruby 1.9.3 后,我的一个应用程序运行良好,但当我尝试使用 capistrano 进行部署时,我尝试转换的第二个应用程序在“assets:precompile”阶段失败。 这是堆栈跟踪:
rake aborted!
rake aborted!
invalid byte sequence in US-ASCII
/Users/george/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.0.4/lib/rake/trace_output.rb:16:in `block in trace_on'
/Users/george/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.0.4/lib/rake/trace_output.rb:14:in `map'
/Users/george/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.0.4/lib/rake/trace_output.rb:14:in `trace_on'
/Users/george/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.0.4/lib/rake/application.rb:328:in `trace'
/Users/george/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.0.4/lib/rake/application.rb:183:in `display_error_message'
/Users/george/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.0.4/lib/rake/application.rb:169:in `rescue in standard_exception_handling'
/Users/george/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.0.4/lib/rake/application.rb:159:in `standard_exception_handling'
/Users/george/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.0.4/lib/rake/application.rb:88:in `load_rakefile'
/Users/george/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.0.4/lib/rake/application.rb:72:in `block in run'
/Users/george/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/george/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
/Users/george/.rvm/gems/ruby-1.9.3-p392@rails3211/bin/ruby_noexec_wrapper:14:in `eval'
/Users/george/.rvm/gems/ruby-1.9.3-p392@rails3211/bin/ruby_noexec_wrapper:14:in `<main>'
我已经阅读了很多帖子并尝试了一些建议,但都无济于事。 我尝试将以下内容添加到我的 gemfile 的顶部:
if RUBY_VERSION =~ /1.9/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end
但这并没有什么不同。
我检查了 LANG 和 LC_ALL 环境变量如下
$ echo $LC_ALL
en_NZ.UTF-8
$ echo $LANG
en_NZ.UTF-8
恐怕我根本不理解消息,我不知道如何识别有问题的文件。
我无法让任何 rake 任务运行 - 它给出了同样的错误。
请注意,我可以在开发模式下完美运行应用程序。
最佳答案
添加
#encoding: utf-8
到你的 Rakefile 的第一行(或者任何有奇怪字符的文件)
关于ruby-on-rails - rake 任务因 US-ASCII 中的无效字节序列而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15947425/