jruby / warbler

Warbler chirpily constructs .war files of your Ruby applications.
Other
883 stars 201 forks source link

do not use sllice_size=0 for compilation - hiding compile errors #388

Closed EugenMayer closed 7 years ago

EugenMayer commented 7 years ago

The default slice_size is 0, which leads to an issue tht e.g. if a gem connot be compiled, lets say erubis due to the syntax issue here: https://github.com/EugenMayer/erubis/commit/d34acfdb7399b64b69bdb8dfb85a596579b4d3cc

then you end up having just a message compilation of .rb file failed and thats it, also with --trace no further information given

Using slice_size 10 here https://github.com/jruby/warbler/blob/master/lib/warbler/jar.rb#L58 , i end up having proper errors like

"tmp/WEB-INF/gems/gems/erubis-2.7.0/lib/erubis/local-setting.rb"
SyntaxError: tmp/WEB-INF/gems/gems/erubis-2.7.0/lib/erubis/helpers/rails_form_helper.rb:126: syntax error, unexpected ':'
      for key, val in html_options:

                            java_send at org/jruby/java/proxies/JavaProxy.java:363
                                parse at file:/root/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/gems/jruby-jars-9.1.2.0/lib/jruby-core-9.1.2.0-complete.jar!/jruby/jruby.rb:59
                           compile_ir at file:/root/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/gems/jruby-jars-9.1.2.0/lib/jruby-core-9.1.2.0-complete.jar!/jruby/jruby.rb:71
  block in compile_files_with_options at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:161
  block in compile_files_with_options at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:297
                                 each at org/jruby/RubyArray.java:1593
           compile_files_with_options at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:281
                         compile_argv at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:94
                                <top> at uri:classloader:/META-INF/jruby.home/bin/jrubyc:5
warble aborted!
Compilation of .rb files failed (pid 1467 exit 1)
/root/.rbenv/versions/jruby-9.1.2.0/bin/warble:1:in `<top>'
Tasks: TOP => compiled => war:compiled
(See full trace by running task with --trace)

or

SyntaxError: tmp/WEB-INF/gems/gems/activejob-4.2.6/lib/rails/generators/job/templates/job.rb:1: syntax error, unexpected tLT
<% module_namespacing do -%>

                            java_send at org/jruby/java/proxies/JavaProxy.java:363
                                parse at file:/root/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/gems/jruby-jars-9.1.2.0/lib/jruby-core-9.1.2.0-complete.jar!/jruby/jruby.rb:59
                           compile_ir at file:/root/.rbenv/versions/jruby-9.1.2.0/lib/ruby/gems/shared/gems/jruby-jars-9.1.2.0/lib/jruby-core-9.1.2.0-complete.jar!/jruby/jruby.rb:71
  block in compile_files_with_options at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:161
  block in compile_files_with_options at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:297
                                 each at org/jruby/RubyArray.java:1593
           compile_files_with_options at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:281
                         compile_argv at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/jruby/compiler.rb:94
                                <top> at uri:classloader:/META-INF/jruby.home/bin/jrubyc:5
warble aborted!

for the issue with https://github.com/rails/rails/blob/master/activejob/lib/rails/generators/job/templates/job.rb

I suggest either having a setting in warble.rb to set it to zero, but by default, make it non zero so people do not run into such dead-ends an probably stop there jruby evaluation because "things magically wont compile"

Thanks!

kares commented 7 years ago

there's a default slice size 2500 ... setting the default lower would cause more javac processes to spawn and warbling would get slower. the support that is there is fairly recent to help identifying compilation issues. we're certainly willing to accept PRs for further improving the current state.

EugenMayer commented 7 years ago

@kares my default was zero, not sure if this here is a expectation issue. No matter what your application internal default is ( 2500 ) the configuration default is zero and should be addressed.

kares commented 7 years ago

double checked, that would mean a failure (tested with JRuby 9.1.5.0) and also no compiling :

jruby-9.1.5.0 :001 > [1, 2].each_slice(0) { |slice| puts slice.inspect  }
ArgumentError: invalid slice size
    from org/jruby/RubyArray.java:1777:in `each_slice'
    from (irb):1:in `<eval>'
    from org/jruby/RubyKernel.java:995:in `eval'
    from org/jruby/RubyKernel.java:1296:in `loop'
    from org/jruby/RubyKernel.java:1115:in `catch'
    from org/jruby/RubyKernel.java:1115:in `catch'
    from /opt/local/rvm/rubies/jruby-9.1.5.0/bin/irb:13:in `<main>'
dolzenko commented 1 year ago

Not sure what happened here but with default settings I was getting aforementioned compilation of .rb file failed error, with WARBLER_COMPILED_FILES_SLICE=10 I was able to track it down to

SyntaxError: cache/jruby/2.6.0/gems/actioncable-5.0.7.2/lib/rails/generators/channel/templates/channel.rb:1: syntax error, unexpected '<'
<% module_namespacing do -%>
^