开发者

Rake assets:precompile issue. Invalid UTF-8 byte sequence

开发者 https://www.devze.com 2023-04-10 22:39 出处:网络
Rails 3.1. I\'m trying to precompile assets. $ rake assets:precompile RAILS_ENV=production rake aborted!

Rails 3.1. I'm trying to precompile assets.

$ rake assets:precompile RAILS_ENV=production
  rake aborted!
  /home/user/project/public/assets/jquery-ui.min-0e8a11c7e970b57b4bf5c449cb14480d.js.gz has a invalid UTF-8 b开发者_StackOverflow社区yte sequence
  Tasks: TOP => assets:precompile

  (See full trace by running task with --trace)

Any ideas?


This is an issue with Sprockets. You can fix this for now by removing the umlaut from "a" in the author's name in the comments. Old:

Copyright (c) 2010 - 2011 Johan Säll Larsson

New:

Copyright (c) 2010 - 2011 Johan Sall Larsson


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

config.assets.precompile = %w( files )

instead of

config.assets.precompile += %w( files )

or

config.assets.precompile << %w( files )


This problem appears to be related to Heroku, Sprockets and interpreting non-ascii characters in your stylesheets.

On the first line of your top-level stylesheet, include:

@charset "UTF-8";

The charset directive must be at the top, or heroku's precompile will insert

@charset "US-ASCII";

Please note that if you're using manifests in your top-level stylesheet, you can't use the charset directive as well, since both of them want to be on the first line. My workaround is to include the stylesheets that have non-ascii characters separately in my layout (and not as part of the manifest).

I'd love a better answer than this workaround.

0

精彩评论

暂无评论...
验证码 换一张
取 消