"Encoding::UndefinedConversionError: Input length = 1" with JRuby-1.7.0.RC on Windows XP #336

Closed
efelix opened this Issue Oct 7, 2012 · 12 comments

2 participants

@efelix

Hello!

When I do this:

C:\Documents and Settings\flx>jruby -v
jruby 1.7.0.RC1 (1.9.3p203) 2012-09-25 8e849de on Java HotSpot(TM) Client VM 1.7
.0_07-b11 [Windows XP-x86]

C:\Documents and Settings\flx>jgem install cucumber
Successfully installed json-1.7.5-java
Successfully installed gherkin-2.11.2-java
Successfully installed builder-3.1.3
Successfully installed diff-lcs-1.1.3
Successfully installed cucumber-1.2.1
5 gems installed

Here cucumber fail!!

C:\Documents and Settings\flx>cucumber
Encoding::UndefinedConversionError: Input length = 1
encode at org/jruby/RubyString.java:7468
initialize at json/ext/Parser.java:175
new at json/ext/Parser.java:151
parse at c:/ruby/jruby170/lib/ruby/gems/shared/gems/json-1.7.5-java/lib/j
son/common.rb:155
I18n at c:/ruby/jruby170/lib/ruby/gems/shared/gems/gherkin-2.11.2-java/l
ib/gherkin/i18n.rb:14
Gherkin at c:/ruby/jruby170/lib/ruby/gems/shared/gems/gherkin-2.11.2-java/l
ib/gherkin/i18n.rb:6
(root) at c:/ruby/jruby170/lib/ruby/gems/shared/gems/gherkin-2.11.2-java/l
ib/gherkin/i18n.rb:5
require at org/jruby/RubyKernel.java:1019
(root) at c:/ruby/jruby170/lib/ruby/shared/rubygems/custom_require.rb:1
require at c:/ruby/jruby170/lib/ruby/shared/rubygems/custom_require.rb:36
require at org/jruby/RubyKernel.java:1019
(root) at c:/ruby/jruby170/lib/ruby/gems/shared/gems/gherkin-2.11.2-java/l
ib/gherkin/lexer/i18n_lexer.rb:1
(root) at c:/ruby/jruby170/lib/ruby/shared/rubygems/custom_require.rb:1
require at org/jruby/RubyKernel.java:1019
require at c:/ruby/jruby170/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at c:/ruby/jruby170/lib/ruby/gems/shared/gems/gherkin-2.11.2-java/l
ib/gherkin.rb:1
require at org/jruby/RubyKernel.java:1019
(root) at c:/ruby/jruby170/lib/ruby/shared/rubygems/custom_require.rb:1
require at c:/ruby/jruby170/lib/ruby/shared/rubygems/custom_require.rb:36
load at org/jruby/RubyKernel.java:1045
(root) at c:\ruby\jruby170\bin\cucumber:23

The same with MRI Ruby 1.9.4 with no problem.

C:\Documents and Settings\flx>ruby -v
ruby 1.9.3p194 (2012-04-20) [i386-mingw32]

C:\Documents and Settings\flx>gem install cucumber
Successfully installed gherkin-2.11.2-x86-mingw32
Successfully installed builder-3.1.3
Successfully installed diff-lcs-1.1.3
Successfully installed cucumber-1.2.1
4 gems installed

First time fail ...

C:\Documents and Settings\flx>cucumber
c:/ruby/ruby193/lib/ruby/1.9.1/json/common.rb:148:in encode': "\x81" to UTF-8 i
n conversion from Windows-1252 to UTF-8 (Encoding::UndefinedConversionError)
from c:/ruby/ruby193/lib/ruby/1.9.1/json/common.rb:148:ininitialize'
from c:/ruby/ruby193/lib/ruby/1.9.1/json/common.rb:148:in new'
from c:/ruby/ruby193/lib/ruby/1.9.1/json/common.rb:148:inparse'
from c:/ruby/ruby193/lib/ruby/gems/1.9.1/gems/gherkin-2.11.2-x86-mingw32
/lib/gherkin/i18n.rb:14:in `class:I18n' ......

FIXed!! set windows enviroment var => LANG=en_US.UTF-8

C:\Documents and Settings\flx>cucumber
*** WARNING: You must use ANSICON 1.31 or higher (http://adoxa.110mb.com/ansicon
) to get coloured output on Windows
....

LANG=en_US.UTF-8 not work with cucumber on JRuby.

I do the same test on Ubuntu and work fine.Is a windows issue.

Thanks.

@enebo
JRuby Team member

You must have some features directory and cucmber stuff defined right? When I run this with an empty directory I at least get cucumber to load on windows. I wonder if this has something to do with an individual character we are tripping on?

Also try jruby -J-Dfile.encoding=UTF-8 -S cucumber as a test.

@efelix

I have cucumber features and steps definitions in english lang with ascii characters only.
I tested too with MRI ruby and work fine.
And also test "jruby -J-Dfile.encoding=UTF-8 -S cucumber" before open this issue with same result.

@efelix

I think is not a cucumber problem cause this commad:

jruby -J-Dfile.encoding=UTF-8 -S cucumber --version

... fail with same output than first post.

@enebo
JRuby Team member

Ok so if I run an example like calculator I can probably reproduce this?

@efelix

I'm afraid so.
Tested with 'calculator' example with same issue, ok on MRI but fail with jruby.

@enebo
JRuby Team member

I just used cucumber/examples/i18n/en and that example executed for me in both CMD and also from mingw GIT shell and neither show this behavior. The only two things I can think of off hand is:

  • I am using Java 6 on Win7 and are using Java 7 on XP
  • What differences in gem versions we have

We have had several gems (like json -- which you and I seem to be using the fixed one) where there is a mistake with how bytes are grabbed from Java strings in them. All common gems should be patched and re-released. If you could provide a list of gems I can compare it against my list and see if anything pops out.

@efelix

Here is my gem list:

C:\Documents and Settings\flx\Desktop>jgem list

*** LOCAL GEMS ***

builder (3.1.3)
cucumber (1.2.1)
diff-lcs (1.1.3)
gherkin (2.11.2 java)
json (1.7.5 java)
rake (0.9.2.2)

is enought this info?

@enebo
JRuby Team member

I match on all those gems and I have no issues. It seems unlikely it is because of Java 7, but without some other discovery we are running out of things to try.

@efelix

Ok.
I tested with jdk-1.6.0_35 on Windows XP and work fine, even without UTF-8 explicit settings.
Then is clear a Java 7 problem, what's next step??

@enebo
JRuby Team member

I am hoping something about Java 7 changes some default system properties which explains this behavior. Otherwise we need to determine whether how we work with Java 7 is different or somehow reduce this to a bug which OpenJDK people can fix in future release of Java.

@efelix

I compare all system properties between java 6 and java 7, and hava the same value. Also test jruby and java 7 oracle on ubuntu 12.04 and is working fine.
Then the issue is jwith java 7 on windows.

@efelix

Fixed!! on JRuby 1.7.0 release.

@efelix efelix closed this Oct 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment