Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6.6, JRuby 1.7.0.pre1
    • Fix Version/s: JRuby 1.7.0.pre1
    • Component/s: Application Error
    • Labels:
      None
    • Environment:
      jruby 1.6.6, rails-3.1.1, execjs 1.2.9
    • Number of attachments :
      0

      Description

      I'm seeing behavior extremely similar to JRUBY-5942 in jruby-1.6.6. Running rake assets:precompile works fine in jruby-1.6.5, but in 1.6.6 I get:

      rake aborted!
      can't convert Encoding into String
        (in /home/ubuntu/.rvm/gems/jruby-1.6.6@circle/gems/haml_coffee_assets-0.6.0/vendor/assets/javascripts/hamlcoffee.js.coffee.erb)
      org/jruby/RubyIO.java:3722:in `popen'
      /home/ubuntu/.rvm/gems/jruby-1.6.6@circle/gems/execjs-1.2.9/lib/execjs/external_runtime.rb:165:in `sh'
      /home/ubuntu/.rvm/gems/jruby-1.6.6@circle/gems/execjs-1.2.9/lib/execjs/external_runtime.rb:125:in `exec_runtime'
      org/jruby/RubyBasicObject.java:1700:in `__send__'
      org/jruby/RubyKernel.java:2099:in `send'
      /home/ubuntu/.rvm/gems/jruby-1.6.6@circle/gems/execjs-1.2.9/lib/execjs/external_runtime.rb:27:in `exec'
      /home/ubuntu/.rvm/gems/jruby-1.6.6@circle/gems/execjs-1.2.9/lib/execjs/external_runtime.rb:40:in `compile_to_tempfile'
      /home/ubuntu/.rvm/gems/jruby-1.6.6@circle/gems/execjs-1.2.9/lib/execjs/external_runtime.rb:26:in `exec'
      /home/ubuntu/.rvm/gems/jruby-1.6.6@circle/gems/execjs-1.2.9/lib/execjs/external_runtime.rb:18:in `eval'
      /home/ubuntu/.rvm/gems/jruby-1.6.6@circle/gems/execjs-1.2.9/lib/execjs/external_runtime.rb:32:in `call'
      /home/ubuntu/.rvm/gems/jruby-1.6.6@circle/gems/coffee-script-2.2.0/lib/coffee_script.rb:57:in `compile'
      /home/ubuntu/.rvm/gems/jruby-1.6.6@circle/gems/tilt-1.3.3/lib/tilt/coffee.rb:46:in `evaluate'
      

      the code in question is

      def sh(command)
        output, options = nil, {}
        options[:external_encoding] = @encoding if @encoding
        options[:internal_encoding] = Encoding.default_internal || 'UTF-8'
        IO.popen(command, options) { |f| output = f.read }
        output
      end
      

        Activity

        Hide
        Hiro Asari added a comment -

        Looks like you have Encoding.default_internal being non-nil, and JRuby is not handing it correctly inside IO.popen.

        What is your default internal encoding? Does passing -U to jruby help you?

        Show
        Hiro Asari added a comment - Looks like you have Encoding.default_internal being non- nil , and JRuby is not handing it correctly inside IO.popen . What is your default internal encoding? Does passing -U to jruby help you?
        Hide
        Hiro Asari added a comment -

        A simple reduced test case is:

        $ jruby -v -e 'output = nil; IO.popen("ls",{:internal_encoding => Encoding::EucJP}) { |f| output = f.read }; p output'
        jruby 1.7.0.dev (ruby-1.9.3-p28) (2012-02-02 6601451) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]
        TypeError: can't convert Encoding into String
           popen at org/jruby/RubyIO.java:3785
          (root) at -e:1
        
        Show
        Hiro Asari added a comment - A simple reduced test case is: $ jruby -v -e 'output = nil; IO.popen("ls",{:internal_encoding => Encoding::EucJP}) { |f| output = f.read }; p output' jruby 1.7.0.dev (ruby-1.9.3-p28) (2012-02-02 6601451) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java] TypeError: can't convert Encoding into String popen at org/jruby/RubyIO.java:3785 (root) at -e:1
        Hide
        Niall McCullagh added a comment -

        I can also confirm this behaviour when I upgraded our existing application to 1.6.6. I have also replicated it with a brand new rails application

        Show
        Niall McCullagh added a comment - I can also confirm this behaviour when I upgraded our existing application to 1.6.6. I have also replicated it with a brand new rails application
        Hide
        Hiro Asari added a comment -

        Honestly, this doesn't happen to me. I tried setting default internal encoding as I outlined above, but that doesn't break it for me.

        [☯-1.6.6] awesome31 $ export JRUBY_OPTS='-EEucJP:EucJP --1.9'
        [☯-1.6.6] awesome31 $ jruby -v
        jruby 1.6.6 (ruby-1.9.2-p312) (2012-01-30 5673572) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]
        [☯-1.6.6] awesome31 $ jruby -e 'p Encoding.default_internal'
        #<Encoding:EUC-JP>
        [&#9775;-1.6.6] awesome31 $ jruby -S rake assets:precompile
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/version.rb:2 warning: already initialized constant VERSION
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/version.rb:5 warning: already initialized constant MAJOR
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/version.rb:5 warning: already initialized constant MINOR
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/version.rb:5 warning: already initialized constant BUILD
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/version.rb:5 warning: already initialized constant PATCH
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/version.rb:6 warning: already initialized constant NUMBERS
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake.rb:27 warning: already initialized constant RAKEVERSION
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/early_time.rb:17 warning: already initialized constant EARLY
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/alt_system.rb:32 warning: already initialized constant WINDOWS
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/application.rb:31 warning: already initialized constant DEFAULT_RAKEFILES
        WARNING: Possible conflict with Rake extension: String#ext already exists
        WARNING: Possible conflict with Rake extension: String#pathmap already exists
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/task_arguments.rb:77 warning: already initialized constant EMPTY_TASK_ARGS
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/invocation_chain.rb:49 warning: already initialized constant EMPTY
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_utils.rb:9 warning: already initialized constant RUBY
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_utils.rb:86 warning: already initialized constant LN_SUPPORTED
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:16 warning: already initialized constant DEFAULT
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/dsl_definition.rb:150 warning: already initialized constant DeprecatedCommands
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_list.rb:44 warning: already initialized constant ARRAY_METHODS
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_list.rb:47 warning: already initialized constant MUST_DEFINE
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_list.rb:51 warning: already initialized constant MUST_NOT_DEFINE
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_list.rb:55 warning: already initialized constant SPECIAL_RETURN
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_list.rb:61 warning: already initialized constant DELEGATING_METHODS
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_list.rb:364 warning: already initialized constant DEFAULT_IGNORE_PATTERNS
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_list.rb:370 warning: already initialized constant DEFAULT_IGNORE_PROCS
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake.rb:68 warning: already initialized constant FileList
        /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake.rb:69 warning: already initialized constant RakeFileUtils
        /Users/asari/.rvm/rubies/jruby-1.6.6/bin/jruby /Users/asari/.rvm/rubies/jruby-1.6.6/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
        [&#9775;-1.6.6] awesome31 $ 
        

        Even so, I pushed the fix that addresses the minimal case that I mentioned earlier. It is a83bd13 on the 1.6 branch, and de9e2ac on the master.

        Allen and Niall, could you test the snapshot from http://ci.jruby.org/snapshots/release/ tomorrow morning?

        Thank you.

        Show
        Hiro Asari added a comment - Honestly, this doesn't happen to me. I tried setting default internal encoding as I outlined above, but that doesn't break it for me. [&#9775;-1.6.6] awesome31 $ export JRUBY_OPTS='-EEucJP:EucJP --1.9' [&#9775;-1.6.6] awesome31 $ jruby -v jruby 1.6.6 (ruby-1.9.2-p312) (2012-01-30 5673572) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java] [&#9775;-1.6.6] awesome31 $ jruby -e 'p Encoding.default_internal' #<Encoding:EUC-JP> [&#9775;-1.6.6] awesome31 $ jruby -S rake assets:precompile /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/version.rb:2 warning: already initialized constant VERSION /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/version.rb:5 warning: already initialized constant MAJOR /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/version.rb:5 warning: already initialized constant MINOR /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/version.rb:5 warning: already initialized constant BUILD /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/version.rb:5 warning: already initialized constant PATCH /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/version.rb:6 warning: already initialized constant NUMBERS /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake.rb:27 warning: already initialized constant RAKEVERSION /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/early_time.rb:17 warning: already initialized constant EARLY /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/alt_system.rb:32 warning: already initialized constant WINDOWS /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/application.rb:31 warning: already initialized constant DEFAULT_RAKEFILES WARNING: Possible conflict with Rake extension: String#ext already exists WARNING: Possible conflict with Rake extension: String#pathmap already exists /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/task_arguments.rb:77 warning: already initialized constant EMPTY_TASK_ARGS /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/invocation_chain.rb:49 warning: already initialized constant EMPTY /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_utils.rb:9 warning: already initialized constant RUBY /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_utils.rb:86 warning: already initialized constant LN_SUPPORTED /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:16 warning: already initialized constant DEFAULT /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/dsl_definition.rb:150 warning: already initialized constant DeprecatedCommands /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_list.rb:44 warning: already initialized constant ARRAY_METHODS /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_list.rb:47 warning: already initialized constant MUST_DEFINE /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_list.rb:51 warning: already initialized constant MUST_NOT_DEFINE /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_list.rb:55 warning: already initialized constant SPECIAL_RETURN /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_list.rb:61 warning: already initialized constant DELEGATING_METHODS /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_list.rb:364 warning: already initialized constant DEFAULT_IGNORE_PATTERNS /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake/file_list.rb:370 warning: already initialized constant DEFAULT_IGNORE_PROCS /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake.rb:68 warning: already initialized constant FileList /Users/asari/.rvm/gems/jruby-1.6.6@global/gems/rake-0.9.2.2/lib/rake.rb:69 warning: already initialized constant RakeFileUtils /Users/asari/.rvm/rubies/jruby-1.6.6/bin/jruby /Users/asari/.rvm/rubies/jruby-1.6.6/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets [&#9775;-1.6.6] awesome31 $ Even so, I pushed the fix that addresses the minimal case that I mentioned earlier. It is a83bd13 on the 1.6 branch, and de9e2ac on the master. Allen and Niall, could you test the snapshot from http://ci.jruby.org/snapshots/release/ tomorrow morning? Thank you.
        Hide
        Niall McCullagh added a comment -

        Hi,

        I haven't had a chance to download the snapshot. Though I did install 1.6 head using:

        rvm install --branch jruby-1\_6 jruby-head

        When I ran both your test case and the rake assets:recompile both succeeded.

        Let me know if you want me to test this against the snapshot rather than the 1.6 head.

        Show
        Niall McCullagh added a comment - Hi, I haven't had a chance to download the snapshot. Though I did install 1.6 head using: rvm install --branch jruby-1\_6 jruby-head When I ran both your test case and the rake assets:recompile both succeeded. Let me know if you want me to test this against the snapshot rather than the 1.6 head.
        Hide
        Hiro Asari added a comment -

        Thank you for checking. That is a good indication that my fix is good. I believe that 1.6.7 is going to go out next week, and this will be fixed with that release.

        Show
        Hiro Asari added a comment - Thank you for checking. That is a good indication that my fix is good. I believe that 1.6.7 is going to go out next week, and this will be fixed with that release.

          People

          • Assignee:
            Hiro Asari
            Reporter:
            Allen Rohner
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: