Ivan Schneider
Ivan Schneider

Reputation: 1145

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

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 byte sequence
  Tasks: TOP => assets:precompile

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

Any ideas?

Upvotes: 9

Views: 7795

Answers (3)

Davide Barison
Davide Barison

Reputation: 158

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 )

Upvotes: 3

Jason
Jason

Reputation: 881

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.

Upvotes: 3

nateware
nateware

Reputation: 197

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

Upvotes: 9

Related Questions