Open kgrz opened 11 years ago
Thanks for the detailed report.
I think the encoding issue might be related to querying via http to get assets, we should get them from the disk directly when possible. Might be related to #68 too
(and or detect & deal with encoding properly, I think your fix will work only for files encoded in ISO-8859-1)
ASCII-8BIT to UTF-8 conversion can be done this way without errors. So, files encoded in ISO-8859-1, US-ASCII, ASCII-8BIT and UTF-8 can be converted to UTF-8 encoding without errors.
Unfortunately force_encoding is not (1.8.7 compatible](http://ruby-doc.org/core-1.8.7/String.html) and I doubt doing this is the real solution as force_encoding does not change anything. We should add a test I adress this issue with a cleaner solution.
Just bit by the same bug. Any progress?
I haven't work on this issue, but would sure accept a pull request on it. I doubt replacing the package snippet with force_encoding
would solve all cases.
just stumbled upon this right now, too. why is it trying to convert from utf-8 to ascii anyway? everything is written in utf-8 on my server (hopefully all vendor js, too), output to clients is utf-8. why does it want to convert from utf-8 to ascii?
@doits I suppose this has to do with backwards compatibility. (@j15e mentioned this earlier :)
I do not have any update on this issue but it should indeed be resolved and we have to find a clean solution for this issue.
I could get rid of the error by setting the correct LANG
env var. By doing LANG=en_US.UTF-8
it changed Encoding.default_external
to UTF-8
. Therefore, assetpack does not try to convert things to ASCII
, but to UTF-8
and everything works.
I could do this for apache with phusion passenger by SetEnv LANG en_US.UTF-8
.
I'm also encountering this issue, is there something new? (Setting the env var LANG didn't work in my case.
Can an option be provided to specify which encoding should be used instead of forcing it to the Encoding.default_external?
I encountered this issue today, it would be nice to get a fix thanks
Could you report your full stacktrace @willmoss ? Is it exactly the same as the original issue?
Just encountered this in production as well.
@papanikge unfortunately, this repo is not maintained anymore. see #197 there is many other better up to date assets manager for sinatra
The
assets
part of my app:I'm using
slim
as my templating engine. The app is a "modular" Sinatra app. Not sure if these change the behaviour.The offending part is at the line https://github.com/rstacruz/sinatra-assetpack/blob/master/lib/sinatra/assetpack/package.rb#L101
This is unrelated to the
yui
compressor since changing that to the default compressor also triggers this error. The issue with this error is when compiling/compressing the assets on a per-request basis, the javascripts files won't get sent to the browser:Changing the entire method to the below snippet corrects this behaviour.
Tested this with 1.8.7 (Mac system ruby), 1.9.3-p327, rubinius 1.2.4. Here's the commit in my repo https://github.com/kgrz/sinatra-assetpack/commit/4810b71d58b6087c5a28b8e5a0bf36a409a19bba Will send a PR if this gets tested thoroughly. The tests pass without any error but there are failures which were there before changing this method.
I'm guessing the reason for this happening only in production is that the
combined
method is not used in other environments.Another point to note is that this setup ( assets in
public
directory) cannot used if you want to build the assets first since by default, the built assets get copied intopublic
directory.Here's the stacktrace: