耙资产:预编译问题.UTF-8字节序列无效

Iva*_*der 9 ruby-on-rails-3

Rails 3.1.我正在尝试预编译资产.

$ rake assets:precompile RAILS_ENV=production
  rake aborted!
  /home/user/project/public/assets/jquery-ui.min-0e8a11c7e970b57b4bf5c449cb14480d.js.gz has a invalid UTF-8 byte sequence
  Tasks: TOP => assets:precompile

  (See full trace by running task with --trace)
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

nat*_*are 9

这是Sprockets的问题.您现在可以通过在评论中从作者姓名中的"a"中删除变音来解决此问题.旧:

Copyright (c) 2010 - 2011 Johan Säll Larsson
Run Code Online (Sandbox Code Playgroud)

新:

Copyright (c) 2010 - 2011 Johan Sall Larsson
Run Code Online (Sandbox Code Playgroud)

  • 在违规文件中,搜索正则表达式模式`[^ a-zA-Z0-9*\.()\ /\ - ,:= {}; <>\[\]'+ $ _ \?\ ^\!"%&#@\|]`(用于vim搜索;你可能必须以不同的方式转义某些字符).你应该能够找到像`±`这样的字符并用标准的ASCII字符替换它们很快(那是什么给了我这个错误). (4认同)

小智 3

https://github.com/sstephenson/sprockets/issues/219

config.assets.precompile = %w( files )
Run Code Online (Sandbox Code Playgroud)

代替

config.assets.precompile += %w( files )
Run Code Online (Sandbox Code Playgroud)

或者

config.assets.precompile << %w( files )
Run Code Online (Sandbox Code Playgroud)