lsegal / yard

YARD is a Ruby Documentation tool. The Y stands for "Yay!"
http://yardoc.org
MIT License
1.94k stars 397 forks source link

Ruby 1.9.2: CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT #376

Closed ncri closed 12 years ago

ncri commented 13 years ago

Stack trace: /Users/nico/.rvm/gems/ruby-1.9.2-p0/gems/yard-0.7.2/lib/yard/templates/helpers/html_syntax_highlight_helper.rb:30:in block in html_syntax_highlight_ruby_ripper' /Users/nico/.rvm/gems/ruby-1.9.2-p0/gems/yard-0.7.2/lib/yard/templates/helpers/html_syntax_highlight_helper.rb:22:in each' /Users/nico/.rvm/gems/ruby-1.9.2-p0/gems/yard-0.7.2/lib/yard/templates/helpers/html_syntax_highlight_helper.rb:22:in html_syntax_highlight_ruby_ripper' /Users/nico/.rvm/gems/ruby-1.9.2-p0/gems/yard-0.7.2/lib/yard/templates/helpers/html_syntax_highlight_helper.rb:11:in html_syntax_highlight_ruby' /Users/nico/.rvm/gems/ruby-1.9.2-p0/gems/yard-0.7.2/lib/yard/templates/helpers/html_helper.rb:151:in html_syntax_highlight' /Users/nico/.rvm/gems/ruby-1.9.2-p0/gems/yard-0.7.2/templates/default/method_details/html/source.erb:9:in _erb_cache_28'

lsegal commented 13 years ago

Can you provide steps to reproduce this issue? You need to make sure you set the proper encodings in your source, and potentially in yard's commandline options, if you're using 1.9

ncri commented 13 years ago

Some files use utf 8 encoding, so they have # encoding: utf-8 on the top. I can try to make a test app to reproduce the issue as soon as I find some time, but I'm rather busy currently. ;-)

ncri commented 13 years ago

After fixing a syntax error in my code, this error disappeared.

ncri commented 13 years ago

oops, the error still occurs:

[error]: Exception occurred while generating 'User.html' [error]: CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT

The user class uses # encoding: utf-8

(Sorry for not including these lines before)

lsegal commented 12 years ago

I'd still need a minimal test case that reproduces the issue.

rhunter commented 12 years ago

JRuby 1.6.1 in Ruby 1.9 mode triggers the issue even with an empty file. Switching to 1.8 mode is fine.

export JRUBY_OPTS=--1.9
rvm use jruby-1.6.1

mkdir yard-encoding-issue376
cd yard-encoding-issue376

touch README.md
cat > Gemfile <<-end
  source :rubygems
  gem 'yard', '0.7.2'
  gem 'kramdown', '0.13.3'
end
bundle install
bundle exec yardoc

It triggers the following error:

Encoding::ConverterNotFoundError: code converter not found ({:invalid=>:replace, :replace=>"?"})
           encode at org/jruby/RubyString.java:7171
          htmlify at /tmp/yard-bug/vendor/bundle/jruby/1.9/gems/yard-0.7.2/lib/yard/templates/helpers/html_helper.rb:44
         diskfile at /tmp/yard-bug/vendor/bundle/jruby/1.9/gems/yard-0.7.2/templates/default/layout/html/setup.rb:49
         __send__ at org/jruby/RubyBasicObject.java:1667
             send at org/jruby/RubyKernel.java:2073
   render_section at /tmp/yard-bug/vendor/bundle/jruby/1.9/gems/yard-0.7.2/lib/yard/templates/template.rb:314
rhunter commented 12 years ago

Actually, it looks like JRuby 1.6.4 throws no error. Hmm, that's a pity. The server that will generate our docs only is behind on JRuby versions :-(

lsegal commented 12 years ago

@rhunter that seems to be a third party issue to JRuby and separate from this specific issue-- nothing we can do about that though :(

lsegal commented 12 years ago

Cleaning out issues for the 0.7.3 release, so I will close this issue for now. If you can provide steps to reproduce, please reopen this issue. Thanks!