Asset Pipeline Encoding Issues (UTF-8 and ASCII-8BIT) with an External Stone

I'm trying to create a gem that wraps d3.js, Source can be found at https://github.com/iblue/d3-rails

So, when I include this stone in my gemfile

gem "d3-rails", :git => "git://github.com/iblue/d3-rails.git" 

And when I include javascript in my application.js:

 //=require d3 

Then my merge compilation failed, and my compiled application.js just contain

 throw Error("Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT") 

I am using Rails 3.1.3 and ruby-1.9.3-p125. jQuery uses exactly the same gem structure and it works. What am I doing wrong?

EDIT

I also saw this question: Ruby 1.9 throwing javascript coding error . This is not applicable here, my file is valid UTF-8:

 ruby-1.9.3-p125 :001 > d = File.read("./d3.js") => [...] ruby-1.9.3-p125 :002 > d.encoding => #<Encoding:UTF-8> ruby-1.9.3-p125 :003 > d.valid_encoding? => true 

EDIT 2 :

I also tried to insert some voodoo into my config/environment.rb . This does not work:

 # -*- encoding : utf-8 -*- # Load the rails application require File.expand_path('../application', __FILE__) # --------- VOODOO BEGINS HERE ----------------- Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 # --------- END VOODO -------------------------- # Initialize the rails application Ratecode::Application.initialize! 
+7
source share
1 answer

Is there a bug from the WEBrick server or something else? Does rake assets:precompile ? (don't forget to clear assets after)

If the latter fails, double-check the value of the $ LANG UTF-8 environment variables (with env ). If the rake task works, but the application fails, it could be the env vars server.

+9
source

All Articles