Skip to content

Commit 34e3942

Browse files
committed
Avoid loading jar-dependencies to install gem hook
By requiring a file from jar-dependencies here, we end up activating whatever the default jar-dependencies gem is for the current JRuby runtime. Later on, when the hook is running or gems that use jars simply try to activate a newer jar-dependencies, we get the dreaded version conflict described in jruby/jar-dependencies#86, preventing activation of all libraries. The change here moves the body of the hook into the JRuby defaults.rb for RubyGems rather than loading any files from jar-dependencies itself. This appears to fix issues like those seen in the jruby-9.4.9.0 builds at ruby/rdoc#1229 (bundle exec failing to run due to the version conflict) and may fix other reports. This does not fix issues using a newer jar-dependencies on an older JRuby, unfortunately.
1 parent 963f994 commit 34e3942

File tree

1 file changed

+9
-3
lines changed
  • lib/ruby/stdlib/rubygems/defaults

1 file changed

+9
-3
lines changed

lib/ruby/stdlib/rubygems/defaults/jruby.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,13 @@ def spec_directories_from_classpath
101101
rescue LoadError
102102
end
103103

104-
begin
105-
require 'jar_install_post_install_hook'
106-
rescue LoadError
104+
if defined?(JRUBY_VERSION) && Gem.post_install_hooks.empty?
105+
Gem.post_install do |gem_installer|
106+
unless (ENV['JARS_SKIP'] || ENV_JAVA['jars.skip']) == 'true'
107+
require 'jars/installer'
108+
jars = Jars::Installer.new(gem_installer.spec)
109+
jars.ruby_maven_install_options = gem_installer.options || {}
110+
jars.vendor_jars
111+
end
112+
end
107113
end

0 commit comments

Comments
 (0)