[jruby] Warbler-2.0.5 issues in 9.2.7
C S
cshupp at gmail.com
Sat Jun 8 04:18:32 JST 2019
JRubyists,
I have recently come into an issue getting my maven build to produce a war
file, and the only big change is an upgrade from 9.2.4 to 9.2.7.
During a maven build, the build hangs forever in some warbler code.
The file *'gems\warbler-2.0.5\lib\warbler\traits\bundler.rb' *has the
following method (only top portion shown) that goes into an infinite loop
during my maven build. Running via *rake war* does not exhibit this issue.
Look for the text: #LOOP IS INFINITE
def add_bundler_gems; require 'bundler'
# config.gems.clear allow to add `config.gems` on top of those bundled
config.gem_dependencies = false # Bundler takes care of these
config.bundler = {} if config.bundler == true
bundler_specs.each do |spec|
spec = to_spec(spec)
# Bundler HAX -- fixup bad #loaded_from attribute in fake
# bundler gemspec from bundler/source.rb
if spec.name == 'bundler'
full_gem_path = Pathname.new(spec.full_gem_path)
while ! full_gem_path.join('bundler.gemspec').exist? #LOOP IS INFINITE
full_gem_path = full_gem_path.dirname
# if at top of the path, meaning we cannot find bundler.gemspec, abort.
if full_gem_path.to_s =~ /^[\.\/]$/
warn("Unable to detect bundler spec under
'#{spec.full_gem_path}'' and its sub-dirs")
exit
end
end
#rest of method not shown
The reason the loop is infinite is the bundler gemspec is being looked for here:
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/gems/bundler-1.16.6
An inspection of JRuby's complete jar file shows it is here:
META-INF/jruby.home/lib/ruby/gems/shared/gems/bundler-1.16.6/
To fix this issue locally, I have put the following monkey patch in my rake
file. I use hashes to signify the lines I changed from the original
module Warbler
module Traits
class Bundler
def bundler_specs
bundle_without = config.bundle_without.map { |s| s.to_sym }
definition = ::Bundler.definition
all = definition.specs.to_a
requested = definition.specs_for(definition.groups -
bundle_without).to_a
excluded_git_specs = (all - requested).select { |spec|
::Bundler::Source::Git === spec.source }
excluded_git_specs.each { |spec| spec.groups << :warbler_excluded }
specs = requested + excluded_git_specs
bundler = specs.select do |e| e.name.eql? 'bundler' end.first
########################################
p "Full gem path is #{bundler.full_gem_path}"
#######################################
if (bundler.full_gem_path =~
/\/META-INF\/jruby.home\/lib\/ruby\/stdlib/)
#in jruby's complete jar it isn't in the stdlib it is here:
# META-INF/jruby.home/lib\ruby/gems/shared/gems/bundler-1.16.6/
p "Changing the full gem path"########################################
bundler.full_gem_path=
'uri:classloader:/META-INF/jruby.home/lib/ruby/gems/shared/gems/bundler-1.16.6'#########################################
p "Full gem path is now
#{bundler.full_gem_path}"######################################################
end
specs
end
end
end
end
Output:
mvn clean package:
[INFO] "Full gem path is
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/gems/bundler-1.16.6"
[INFO] "Changing the full gem path"
[INFO] "Full gem path is now
uri:classloader:/META-INF/jruby.home/lib/ruby/gems/shared/gems/bundler-1.16.6"
rake war:
"Full gem path is
C:/languages/ruby/jruby-9.2.7.0/lib/ruby/gems/shared/gems/bundler-1.16.6"
Thanks All,
Cris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ruby-lang.org/pipermail/jruby/attachments/20190607/a45e41a9/attachment.html>
More information about the JRuby
mailing list