耙子流产! UTF-8中的字节序列无效

时间:2013-06-25 22:08:12

标签: ruby-on-rails ruby linux utf-8

这个问题一直困扰着我好几个小时!尝试在AWS实例上预编译我的资产时,我得到以下结果:

bitnami@ip-10-117-75-230:/opt/bitnami/apache2/htdocs/my_broker_app$ sudo bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/opt/bitnami/ruby/bin/ruby /opt/bitnami/ruby/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
rake aborted!
invalid byte sequence in UTF-8
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/hike-1.2.3/lib/hike/index.rb:82:in `block in entries'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/hike-1.2.3/lib/hike/index.rb:82:in `reject'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/hike-1.2.3/lib/hike/index.rb:82:in `entries'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:116:in `entries'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:185:in `each_entry'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:190:in `block in each_entry'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:185:in `each'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:185:in `each_entry'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:190:in `block in each_entry'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:185:in `each'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:185:in `each_entry'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:190:in `block in each_entry'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:185:in `each'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:185:in `each_entry'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:190:in `block in each_entry'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:185:in `each'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:185:in `each_entry'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/sprockets/static_compiler.rb:18:in `compile'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:56:in `internal_precompile'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/opt/bitnami/ruby/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/opt/bitnami/ruby/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/bin/rake:33:in `<top (required)>'
/opt/bitnami/ruby/bin/rake:23:in `load'
/opt/bitnami/ruby/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile:primary
rake aborted!
Command failed with status (1): [/opt/bitnami/ruby/bin/ruby /opt/bitnami/ru...]
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/file_utils.rb:45:in `call'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/file_utils.rb:45:in `sh'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/file_utils_ext.rb:37:in `sh'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/file_utils.rb:80:in `ruby'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/file_utils_ext.rb:37:in `ruby'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/opt/bitnami/ruby/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
/opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rake-10.0.4/bin/rake:33:in `<top (required)>'
/opt/bitnami/ruby/bin/rake:23:in `load'
/opt/bitnami/ruby/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile

我正在运行ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]

3 个答案:

答案 0 :(得分:2)

我通过以下方式解决了这个问题:

$ cd opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/hike-1.2.3/lib/hike
$ sudo chmod 777 index.rb
$ sudo vim index.rb

然后,在第一行之前插入(按键盘上的i字样):# encoding: utf-8

点击esc,然后点击:wq,然后按enter进行保存。

之后,通过执行以下操作为index.rb添加权限

$ sudo chmod 644 index.rb

希望这可以帮助将来的某个人。

答案 1 :(得分:1)

如果有其他人遇到这个问题,虽然Tomanow的答案对我来说不起作用,但我发现我的文件中有令人讨厌的字符,这就是造成这个问题的原因。

来自Open Layers版本2.13的文件在其某些javascript和css文件的评论部分中包含版权符号。任何有类似问题的人也可以尝试查找并删除这些字符,如果这是可行的。查看this answer了解详情。

答案 2 :(得分:0)

就我而言,每个佣金任务都会出现问题。我发现这是因为在应用程序的主目录中意外创建了一些奇怪名称的文件,例如“?”和“\ 342”。我删除它们后一切正常。