Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Encoding::CompatibilityError exception using UTF-8 locals with Haml on JRuby (1.9 mode) #83

aXe1 opened this Issue Apr 28, 2011 · 3 comments


None yet
3 participants

aXe1 commented Apr 28, 2011

When using non-ASCII locals (e.g. cyrillic) in souce encoded in UTF-8 without BOM and Haml template (must include non-ASCII characters too) UTF-8 - Encoding::CompatibilityError exception raises.

tilt1.rb (UTF-8 without BOM):

# encoding: utf-8
require 'haml'
require 'tilt'

template = Tilt.new('tilt1.haml')
puts template.render(self, :test_var => 'проверка')

tilt1.haml (UTF-8 without BOM):

-# encoding: utf-8
%p проверка
%p= test_var

Running on JRuby with command-line parameter --1.9 causes exception, but with --1.8 command-line parameter or on MRI Ruby it works as expected.

C:\aXe1\dev\ruby\test\jruby>jruby --1.9 tilt1.rb
Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and U
  evaluate_source at tilt1.haml:3
             eval at org/jruby/RubyKernel.java:1093
  evaluate_source at c:/jruby/jruby-1.6.1/lib/ruby/gems/1.9/gems/tilt-1.3/lib/ti
    instance_eval at org/jruby/RubyBasicObject.java:1699
  evaluate_source at c:/jruby/jruby-1.6.1/lib/ruby/gems/1.9/gems/tilt-1.3/lib/ti
  cached_evaluate at c:/jruby/jruby-1.6.1/lib/ruby/gems/1.9/gems/tilt-1.3/lib/ti
         evaluate at c:/jruby/jruby-1.6.1/lib/ruby/gems/1.9/gems/tilt-1.3/lib/ti
         evaluate at c:/jruby/jruby-1.6.1/lib/ruby/gems/1.9/gems/tilt-1.3/lib/ti
           render at c:/jruby/jruby-1.6.1/lib/ruby/gems/1.9/gems/tilt-1.3/lib/ti
           (root) at tilt1.rb:7

C:\aXe1\dev\ruby\test\jruby>jruby --1.8 tilt1.rb

C:\aXe1\dev\ruby\test\jruby>ruby tilt1.rb

Don't see on incorrect characters above - it's ok, cause my console has CP866 encoding and not UTF-8.
Similar template in Erb works ok.

My environment:

C:\aXe1\dev\ruby\test\jruby>jgem list tilt

*** LOCAL GEMS ***

tilt (1.3)

C:\aXe1\dev\ruby\test\jruby>jgem list haml

*** LOCAL GEMS ***

haml (3.1.1)

C:\aXe1\dev\ruby\test\jruby>jruby -v
jruby 1.6.1 (ruby-1.9.2-p136) (2011-04-12 85838f6) (Java HotSpot(TM) Client VM 1
.6.0_21) [Windows 7-x86-java]

C:\aXe1\dev\ruby\test\jruby>ruby -v
ruby 1.9.2p180 (2011-02-18) [i386-mingw32]

rkh commented Apr 29, 2011

Does it work on MRI 1.9? If so, please file a JRuby issue.

aXe1 commented Apr 29, 2011

Yes. Both on MRI 1.9 and JRuby in 1.8 mode.
Maybe it is related to [#JRUBY-5754].


judofyr commented Apr 28, 2013

Try again with Tilt from master. Re-open if this is still occurs.

@judofyr judofyr closed this Apr 28, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment