Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jruby 9.x jar-dependencies thwarts `gem install` prereq. to gemspec #3078

Closed
dekellum opened this Issue Jun 22, 2015 · 10 comments

Comments

Projects
None yet
2 participants
@dekellum
Copy link
Contributor

dekellum commented Jun 22, 2015

As of at least 9.0.0.0.rc1 and the current travis-ci jruby-head, the built in jar-dependencies extension is loading and attempting to interpret a gemspec found in the current directory and even for such commands as gem install. In the case of several of my projects building on travis-ci, I need to run gem install to satisfy a dependency of the project's gemspec, before the gemspec can be successfully loaded. Note this all works fine on MRI ruby as well as jruby 1.7.x.

To reproduce:

% jruby -v
jruby 9.0.0.0.rc1 (2.2.2) 2015-06-10 a0bf3b3 OpenJDK 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [linux-amd64]
% jgem uninstall rjack-tarpit # just in case you already have it.
% git clone https://github.com/dekellum/mojibake.git
% cd mojibake
% gem install rjack-tarpit
/usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1:in `require':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1:in `require':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
Gem::LoadError: Could not find 'rjack-tarpit' (~> 2.1) among 27 total gem(s)
Checked in 'GEM_PATH=/home/david/.gem/jruby/2.2.0:/usr/local/lib/jruby/gems', execute `gem env` for more information
            to_specs at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/rubygems/dependency.rb:315
             to_spec at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/rubygems/dependency.rb:324
                 gem at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/rubygems/core_ext/kernel_gem.rb:64
              <eval> at (eval):3
                eval at org/jruby/RubyKernel.java:979
      block in setup at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/jars/maven_exec.rb:33
               chdir at org/jruby/RubyDir.java:324
               setup at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/jars/maven_exec.rb:32
          initialize at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/jars/maven_exec.rb:22
          initialize at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/jars/classpath.rb:10
  require_jars_lock! at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/jar_dependencies.rb:162
   require_jars_lock at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/jar_dependencies.rb:173
         require_jar at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/jar_dependencies.rb:179
         require_jar at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/jar_dependencies.rb:263
               <top> at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/psych_jars.rb:5
             require at org/jruby/RubyKernel.java:940
              (root) at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
               <top> at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:128
             require at org/jruby/RubyKernel.java:940
              (root) at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/psych.rb:3
               <top> at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
             require at org/jruby/RubyKernel.java:940
             require at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:128
              (root) at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/yaml.rb:5
              (root) at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
             require at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:128
           load_yaml at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/rubygems.rb:624
           load_file at /usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/rubygems/config_file.rb:328
               <top> at /usr/local/bin/jgem:22

Here is a travis build with the problem. Note this also results in a "bundle: command not found" warning/error in that environment:

https://travis-ci.org/dekellum/mojibake/jobs/67886026#L172

Note that supplying the JARS_SKIP environment setting does not avoid this issue. #1974 seemed to suggest that would be a workaround.

A simple/silly workaround is to add an empty 'another.gemspec' to the working directory. Apparently jar-dependencies gives up trying to load a gemspec if there are two files with that extension. Here is a working build with that workaround:

https://travis-ci.org/dekellum/mojibake/jobs/67891335

This is similar to issue #1975 as was previously resolved by mkristian/jar-dependencies@0250839. Possibly other fixes in jruby 9, have made this the LoadError is should be, and above referenced fix does not successfully rescue LoadError.

I will provide a pull request fixing this to the jar-dependencies project.

@mkristian

This comment has been minimized.

Copy link
Member

mkristian commented Jun 23, 2015

closing as duplicate of #3074 - I did release jar-dependencies-0.1.15 yesterday and patched jruby-1_7 branch to use it.travis was not happy with this. will merge it to master once jruby-1_7 is happy on travis.

please install the latest jar-dependencies and see if this helps. but any PR to improve things is welcome ;)

@mkristian mkristian closed this Jun 23, 2015

@mkristian mkristian added this to the Invalid or Duplicate milestone Jun 23, 2015

@dekellum

This comment has been minimized.

Copy link
Contributor Author

dekellum commented Jun 23, 2015

Why would you immediately close this as a duplicate given the different error, gemspec particulars, commands it fails on, and without confirming any fix? I can't find any change in jar-dependencies 0.1.15 that would solve this issue. Did you have any particular commit(s) in mind?

I based my proposed fix off of the current master: mkristian/jar-dependencies#24

@mkristian

This comment has been minimized.

Copy link
Member

mkristian commented Jun 23, 2015

yes, maybe I was to hasty - sorry. the change from, yesterday was not to look at gemspec at all on require_jar which happens for example when you require psych. but you are right I need to verify the new version of jar-dependencies against your problem and release a new jar-dependencies if needed.

@mkristian

This comment has been minimized.

Copy link
Member

mkristian commented Jun 23, 2015

thanx for the test-case which works with current master.

was duplicate of #3074 and is fixed with 0cce926

@dekellum

This comment has been minimized.

Copy link
Contributor Author

dekellum commented Jun 23, 2015

Thank you for merging mkristian/jar-dependencies#24. However you merged this after releasing 0.1.15. I confirmed that the fix is not present on either the maven central or rubygems versions of the jar-dependencies gem.

I still don't see how this is either a duplicate or #3074 or how the upgrade to 0.1.15 (without the rescue change) fixes this? Perhaps there is some confusion between released and your local development versions of jar-dependencies 0.1.15?

Please advise.

@mkristian

This comment has been minimized.

Copy link
Member

mkristian commented Jun 23, 2015

yes, I released 0.1.15 yesterday and your PR came after the release.

then I used you "test case" to verify 0,1.15 is fixing you problem as well, why I thought in the beginning that this is duplicate of #3074 is the psych problem you also have:

% gem install rjack-tarpit
/usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1:in `require':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/usr/local/lib/jruby/jruby-9.0.0.0.rc1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1:in `require':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.

and without those issues the gem install rjack-tarpit works - at least it did for me and never build a gem with your PR.

if you still see your problem with jar-dependencies-0.1.15 please reopen this issue.

@dekellum

This comment has been minimized.

Copy link
Contributor Author

dekellum commented Jun 23, 2015

I don't see how that could work. Installing jar-dependencies -v0.1.15 doesn't work. The nightly snapshot still has jar-dependencies 0.1.14:

 http://ci.jruby.org/snapshots/master/jruby-dist-9.0.0.0-SNAPSHOT-bin.tar.gz
 2015-06-23T04:56:31.000Z

...so unless you can kick one of those off for me, I wait 12 hours for the next run?

Heh, as if I had permission to reopen.

@mkristian mkristian reopened this Jun 23, 2015

@mkristian

This comment has been minimized.

Copy link
Member

mkristian commented Jun 23, 2015

I do not know about the permissions ;).

are you saying jgem install jar-dependencies does not work ?

I did upload my current snapshot to: https://oss.sonatype.org/content/repositories/snapshots/org/jruby/jruby-dist/9.0.0.0-SNAPSHOT/

@dekellum

This comment has been minimized.

Copy link
Contributor Author

dekellum commented Jun 23, 2015

OK, I can confirm that your latest snapshot does work correctly, thanks. I can only infer that this avoids spinning up jar-dependencies and attempting to read my project gemspec as a result of gem install, where I might for example have a gem like psych in local gems or as part of jruby?

That does seem better, to avoid the jar-dependencies involvement in the first place!

@mkristian

This comment has been minimized.

Copy link
Member

mkristian commented Jun 23, 2015

yes, gem install ... has no business to look at gemspec files on the current working directory. thanx for being persistent and know that another "edge" case works fine now.

@mkristian mkristian closed this Jun 23, 2015

dekellum added a commit to dekellum/fishwife that referenced this issue Jun 24, 2015

Workaround for LoadError via current travis jruby-head jar-dependencies.
Add a second (empty) gemspec to confuse jruby's jar-dependencies into
not loading the main gemspec when the prerequisite `gem install
rjack-tarpit` is run. Otherwise the main gemspec will throw a
LoadError. Cart before the horse, etc.

See jruby/jruby#3078 and note that despite claims in jruby/jruby#1974
setting JARS_SKIP does not avoid this issue.

dayyan pushed a commit to dayyan/jflow that referenced this issue Apr 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.