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

Failing to build warfile with JRuby 9.2.7.0 #451

Closed
HarlemSquirrel opened this issue May 9, 2019 · 10 comments

Comments

@HarlemSquirrel
Copy link

@HarlemSquirrel HarlemSquirrel commented May 9, 2019

➤  ruby -v
jruby 9.2.7.0 (2.5.3) 2019-04-09 8a269e3 OpenJDK 64-Bit Server VM 25.212-b04 on 1.8.0_212-b04 [linux-x86_64]

➤  bundle -v
Bundler version 1.17.3
╭─kem2028@pc200230 ~/code/iam-admin ‹jruby-9.2.7.0› ‹jruby-9.2.7.0› 

➤  rake war
NOTE: ActiveRecord 4.2 with adapter: mssql is not (yet) fully supported by AR-JDBC, please consider helping us out.
~/.rvm/rubies/jruby-9.2.7.0/lib/ruby/gems/shared/gems/bundler-1.16.6/lib/bundler/vendor/fileutils/lib/fileutils.rb:1186: warning: already initialized constant S_IF_DOOR
~/.rvm/rubies/jruby-9.2.7.0/lib/ruby/gems/shared/gems/bundler-1.16.6/lib/bundler/vendor/fileutils/lib/fileutils.rb:1444: warning: already initialized constant DIRECTORY_TERM
~/.rvm/rubies/jruby-9.2.7.0/lib/ruby/gems/shared/gems/bundler-1.16.6/lib/bundler/vendor/fileutils/lib/fileutils.rb:1446: warning: already initialized constant SYSCASE
~/.rvm/rubies/jruby-9.2.7.0/lib/ruby/gems/shared/gems/bundler-1.16.6/lib/bundler/vendor/fileutils/lib/fileutils.rb:1499: warning: already initialized constant OPT_TABLE
~/.rvm/rubies/jruby-9.2.7.0/lib/ruby/gems/shared/gems/bundler-1.16.6/lib/bundler/vendor/fileutils/lib/fileutils.rb:1553: warning: already initialized constant LOW_METHODS
~/.rvm/rubies/jruby-9.2.7.0/lib/ruby/gems/shared/gems/bundler-1.16.6/lib/bundler/vendor/fileutils/lib/fileutils.rb:1560: warning: already initialized constant METHODS
rake aborted!
ArgumentError: Trying to register Bundler::GemfileError for status code 4 but Bundler::GemfileError is already registered
~/.rvm/gems/jruby-9.2.7.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:1:in `block in (root)'
~/.rvm/gems/jruby-9.2.7.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require'
~/.rvm/gems/jruby-9.2.7.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency'
~/.rvm/gems/jruby-9.2.7.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `<main>'
~/.rvm/gems/jruby-9.2.7.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:1:in `(root)'
~/.rvm/gems/jruby-9.2.7.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require'
~/.rvm/gems/jruby-9.2.7.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency'
~/.rvm/gems/jruby-9.2.7.0/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require'
~/.rvm/gems/jruby-9.2.7.0/gems/warbler-2.0.5/lib/warbler/traits/bundler.rb:34:in `block in add_bundler_gems'
~/.rvm/gems/jruby-9.2.7.0/gems/warbler-2.0.5/lib/warbler/traits/bundler.rb:31:in `after_configure'
~/.rvm/gems/jruby-9.2.7.0/gems/warbler-2.0.5/lib/warbler/traits.rb:33:in `after_configure'
~/.rvm/gems/jruby-9.2.7.0/gems/warbler-2.0.5/lib/warbler/traits.rb:33:in `after_configure'
~/.rvm/gems/jruby-9.2.7.0/gems/warbler-2.0.5/lib/warbler/config.rb:217:in `initialize'
config/warble.rb:6:in `<main>'
~/.rvm/gems/jruby-9.2.7.0/gems/warbler-2.0.5/lib/warbler/task.rb:46:in `initialize'
~/code/iam-admin/Rakefile:11:in `<main>'
(See full trace by running task with --trace)
@HarlemSquirrel

This comment has been minimized.

Copy link
Author

@HarlemSquirrel HarlemSquirrel commented May 22, 2019

I have a couple of version of Bundler installed.

➤  gem list bundler

*** LOCAL GEMS ***

bundler (2.0.1, 1.17.3, 1.16.6)

I am able to build the war using bundle exec rake war.

@HarlemSquirrel

This comment has been minimized.

Copy link
Author

@HarlemSquirrel HarlemSquirrel commented May 22, 2019

This guide suggests using binstubs but the default bin/rake provided by Rails does not work either.

https://thoughtbot.com/blog/but-i-dont-want-to-bundle-exec

@JesseChavez

This comment has been minimized.

Copy link

@JesseChavez JesseChavez commented May 23, 2019

I have seen bundler and JRuby don't play well, try to downgrade to JRuby 9.2.6.0

Warbler and JRuby 9.2.6.0 works for me.

Look at a related issue:

jruby/jruby#5721

@HarlemSquirrel

This comment has been minimized.

Copy link
Author

@HarlemSquirrel HarlemSquirrel commented May 23, 2019

Here we go: jruby/jruby#5686 (comment)

The Bundler in stdlib was an oversight...the RubyGems updater now installs Bundler alongside RubyGems as a standard library, rather than just as a preinstalled gem.

I have already removed the files on master for 9.2.8, and I did confirm that installing a newer Bundler does override the one in stdlib, as it should. Does that not seem to be the case in your setup?

As a workaround, we can use bundle exec rake war which is perhaps what we should be using anyhow.

@darmbrust

This comment has been minimized.

Copy link

@darmbrust darmbrust commented Jun 7, 2019

Not sure if I have the same issue, but when I'm building a project with JRuby and Maven, with 9.2.7.0, the build infinitely hangs.

[INFO] Execute:Java13CommandLauncher: Executing '/apps/jdk1.8.0_191/jre/bin/java' with arguments:
'-cp'
'/apps/maven_repo_local/org/jruby/jruby-complete/9.2.7.0/jruby-complete-9.2.7.0.jar'
'-Xmx4000m'
'-Djava.awt.headless=true'
'-Xbootclasspath/a:/apps/maven_repo_local/org/jruby/jruby-complete/9.2.7.0/jruby-complete-9.2.7.0.jar'
'org.jruby.Main'
'-I'
'/apps/jenkins_data/workspace/uts-web-editor_develop/lib'
'-r'
'jars/setup'
'/tmp/ruby-gems/editor/bin/rake'
'RAILS_ENV=test'
'RAILS_RELATIVE_URL_ROOT=/editor'
'PROJECT_VERSION=6.23-SNAPSHOT'
'devops:build_war'
......
[INFO] "Build war file"
[INFO] "build the version file with version 6.23-SNAPSHOT"
[INFO] "Compile assets"
......
[INFO] I, [2019-06-07T19:39:02.480995 #2336] INFO -- : Writing /apps/jenkins_data/workspace/uts-web-editor_develop/public/assets/jquery-ui/ui-bg_flat_0_aaaaaa_40x100-ae65a7ae22c4c23115948fdeb5c05c9137dbd13ca2d426b3c4c3c4183451e410.png
[INFO] "build the context file"

It hangs here - never to return.
My profiler tells me it was stuck in a loop doing these sorts of operations, using 100% CPU:

at java.io.UnixFileSystem.getLastModifiedTime(Native Method) at java.io.File.lastModified(File.java:943) at org.jruby.util.JarCache$JarIndex.isValid(JarCache.java:108) at org.jruby.util.JarCache.getIndex(JarCache.java:135) - locked <0x00000006c6368638> (a java.util.WeakHashMap) at org.jruby.util.JarResource.createJarResource(JarResource.java:47) at org.jruby.util.JarResource.create(JarResource.java:40) at org.jruby.util.URLResource.addDirectoryEntries(URLResource.java:238) at org.jruby.util.URLResource.addDirectoriesFromClassloader(URLResource.java:227) at org.jruby.util.URLResource.createClassloaderURI(URLResource.java:207) at org.jruby.util.URLResource.create(URLResource.java:264) at org.jruby.util.JRubyFile.createResource(JRubyFile.java:104) at org.jruby.util.JRubyFile.createResource(JRubyFile.java:77) at org.jruby.RubyFileTest.exist(RubyFileTest.java:130) at org.jruby.RubyFileTest.exist_p(RubyFileTest.java:124) at org.jruby.RubyFileTest$INVOKER$s$1$0$exist_p.call(RubyFileTest$INVOKER$s$1$0$exist_p.gen

Reverting to 9.2.6.0 fixes the issue.

@F2Andy

This comment has been minimized.

Copy link

@F2Andy F2Andy commented Jul 17, 2019

I also have Warbler hanging infinitely with JRuby 9.2.7. I got around it by using an earlier version of JRuby too.

@cshupp1

This comment has been minimized.

Copy link

@cshupp1 cshupp1 commented Aug 8, 2019

I wrote this to the JRuby mailer with my patch to this. Perhaps it will help some of you.

Date: Fri, 7 Jun 2019 15:18:32 -0400
Subject: [jruby] Warbler-2.0.5 issues in 9.2.7
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

@cshupp1

This comment has been minimized.

Copy link

@cshupp1 cshupp1 commented Aug 8, 2019

@cshupp1

This comment has been minimized.

Copy link

@cshupp1 cshupp1 commented Aug 14, 2019

@HarlemSquirrel you may be able to close this if you try 9.2.8. My maven build no longer hangs in warbler, and I don't need the monkey patch I referenced above.

@HarlemSquirrel

This comment has been minimized.

Copy link
Author

@HarlemSquirrel HarlemSquirrel commented Aug 15, 2019

JRuby 9.2.8.0 worked like a charm to again be able to build my war file with just rake war!

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