mkristian / jar-dependencies

manage jar dependencies for ruby gems
MIT License
34 stars 19 forks source link

NameError: uninitialized constant #<Class:0x...>::SKIP_LOCK #47

Closed dgolombek closed 8 years ago

dgolombek commented 8 years ago

I'm building a jar with Gradle and jruby-gradle-storm-plugin and jruby-gradle-plugin. After Gradle upgraded itself to 2.2.1, Jars::SKIP_LOCK is no longer defined and jar-dependencies barfs every time it tries to load. I can't figure out where SKIP_LOCK is defined, but it's clear that whatever is defining Jars::MAVEN_SETTINGS is no longer defining Jars::SKIP_LOCK. If I change jar_dependencies.rb to not assume co-definition and check for definition of SKIP_LOCK on its own then things start working again. I know I'm missing a ton of details about exact versions -- I'm just not sure if Gradle+Maven jar versions are important or ruby gem versions are defining this. Please let me know what information I can provide to help debug.

NameError: uninitialized constant #<Class:0x2e09c51>::SKIP_LOCK
  const_missing at org/jruby/RubyModule.java:3181
     skip_lock? at /Users/dgolombek/src/evergreen_topologies/build/tmp/jrubyExec/gems/jar-dependencies-0.3.3/lib/jar_dependencies.rb:126
    require_jar at /Users/dgolombek/src/evergreen_topologies/build/tmp/jrubyExec/gems/jar-dependencies-0.3.3/lib/jar_dependencies.rb:286
    require_jar at /Users/dgolombek/src/evergreen_topologies/build/tmp/jrubyExec/gems/jar-dependencies-0.3.3/lib/jar_dependencies.rb:390
          <top> at /Users/dgolombek/src/evergreen_topologies/build/tmp/jrubyExec/gems/fast-rsa-engine-0.3.2-java/lib/fast-rsa-engine_jars.rb:4
        require at org/jruby/RubyKernel.java:939
        require at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:69
          <top> at /Users/dgolombek/src/evergreen_topologies/build/tmp/jrubyExec/gems/fast-rsa-engine-0.3.2-java/lib/fast-rsa-engine.rb:1
        require at org/jruby/RubyKernel.java:939
        require at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:128
          <top> at scripts/evergreen_topology_smoke.rb:4
mkristian commented 8 years ago

@dgolombek jar-dependencies comes with the jruby jar itself and before version 0.3.1 there was no SKIP_LOCK. even if I do not understand why both jar_dependencies.rb files can be loaded, could just verify if your jar has /META-INF/jruby.home/lib/ruby/stdlib/jar_dependencies.rb without this SKIP_LOCK

if this is the case I would release a bug fix version with some extra check on SKIP_LOCK to be on the save side

dgolombek commented 8 years ago

My war has META-INF/jruby.home/lib/ruby/shared/jar_dependencies.rb NOT stdlib:

(=2b07b) dgolombek@THQ_M_DGOLO02 ~/src/evergreen_topologies> jar tvf build/libs/evergreen_topologies-1.1.0-SNAPSHOT.jar |grep jar_dependencies.rb
  9235 Thu Aug 20 12:02:24 EDT 2015 META-INF/jruby.home/lib/ruby/shared/jar_dependencies.rb
 11852 Tue Dec 01 14:37:50 EST 2015 gems/jar-dependencies-0.3.0/lib/jar_dependencies.rb
 12395 Fri May 13 11:38:38 EDT 2016 gems/jar-dependencies-0.3.2/lib/jar_dependencies.rb
 12463 Fri May 13 11:16:52 EDT 2016 gems/jar-dependencies-0.3.3/lib/jar_dependencies.rb

Sure enough, no SKIP_LOCK inside that file:

  unless defined? Jars::MAVEN_SETTINGS
    MAVEN_SETTINGS = 'JARS_MAVEN_SETTINGS'.freeze
    LOCAL_MAVEN_REPO = 'JARS_LOCAL_MAVEN_REPO'.freeze
    # lock file to use
    LOCK = 'JARS_LOCK'.freeze
    # where the locally stored jars are search for or stored
    HOME = 'JARS_HOME'.freeze
    # skip the gem post install hook
    SKIP = 'JARS_SKIP'.freeze
    # do not require any jars if set to false
    REQUIRE = 'JARS_REQUIRE'.freeze
    # @private
    NO_REQUIRE = 'JARS_NO_REQUIRE'.freeze
    # no more warnings on conflict. this still requires jars but will
    # not warn. it is needed to load jars from (default) gems which
    # do contribute to any dependency manager (maven, gradle, jbundler)
    QUIET = 'JARS_QUIET'.freeze
    # show maven output
    VERBOSE = 'JARS_VERBOSE'.freeze
    # maven debug
    DEBUG = 'JARS_DEBUG'.freeze
    # vendor jars inside gem when installing gem
    VENDOR = 'JARS_VENDOR'.freeze
    # resolve jars from Jars.lock
    RESOLVE = 'JARS_RESOLVE'.freeze
  end

(=2b07b) dgolombek@THQ_M_DGOLO02 ~/src/evergreen_topologies> unzip -p build/libs/evergreen_topologies-1.1.0-SNAPSHOT.jar META-INF/jruby.home/lib/ruby/shared/jar_dependencies.rb | shasum bc887df0e3aeaa3eb8ae98cf87859637656cb7c9 - (=2b07b) dgolombek@THQ_M_DGOLO02 ~/src/evergreen_topologies> unzip -p build/libs/evergreen_topologies-1.1.0-SNAPSHOT.jar META-INF/jruby.home/lib/ruby/shared/jar_dependencies.rb | md5 df7d65ad7232a11aa4e88c57ce40395d

dgolombek commented 8 years ago

It looks like I'm getting jar-dependencies 0.1.15 from JRuby and 0.3.3 from Gradle

2b07b) dgolombek@THQ_M_DGOLO02 ~/src/evergreen_topologies> jar tvf build/libs/evergreen_topologies-1.1.0-SNAPSHOT.jar |grep jar-dependencies|grep gemspec
  2181 Thu Aug 20 12:02:20 EDT 2015 META-INF/jruby.home/lib/ruby/gems/shared/specifications/default/jar-dependencies-0.1.15.gemspec
  1575 Fri May 13 11:16:52 EDT 2016 gems/jar-dependencies-0.3.3/jar-dependencies.gemspec
  1942 Fri May 13 11:16:52 EDT 2016 specifications/jar-dependencies-0.3.3.gemspec
mkristian commented 8 years ago

0.1.15 rings a bell on the jruby-gradle-plugin as we found out there that this version is somehow hardcoded inside the plugin. so this gradle plugin could need a fix and release as well.

I will let you know once things are released. thanks for digging into this.

mkristian commented 8 years ago

@dgolombek please try version 0.3.4 of jar-dependencies and if this works I go and see the gradle plugin ;)

dgolombek commented 8 years ago

Yep, 0.3.4 fixes the problem, thank you!