jruby/warbler

Ignoring mimemagic-0.3.9 because its extensions are not built. Try: gem pristine mimemagic --version 0.3.9

mbiang opened this issue · 5 comments

Recently had to upgrade Mimemagic to version 0.3.9 because version 0.3.2 was pulled from RubyGems.

After rebuilding our WAR file, we are getting the following error message in our Tomcat logs:
Ignoring mimemagic-0.3.9 because its extensions are not built. Try: gem pristine mimemagic --version 0.3.9

The app itself produces the following error when tryin to view it:

Could not find mimemagic-0.3.9 in any of the sources from uri:classloader

Does anyone have any insight or direction for where to go next here?

Same problem with mimemagic 0.4.3.

Looking at what happens when I install mimemagic locally it seems that it generates a file .rbenv/versions/jruby-9.2.17.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.5.0/mimemagic-0.4.3/mimemagic/path.rb while the rest of the library is installed in .rbenv/versions/jruby-9.2.17.0/lib/ruby/gems/shared/gems/mimemagic-0.4.3/

On the other hand in the war I only find gems/gems/mimemagic-0.4.3 without a corresponding gems/extensions/universal-java-1.8/2.5.0/mimemagic-0.4.3/mimemagic/path.rb.
Of course even if it was present there it would probably contain the wrong path as I develop on a mac and deploy to a linux server.

I can however confirm that copying the extensions directory to the WEB-INF/gems/ directory gets me past the "Ignoring because extensions are not built", I'm not quite sure how to automatically add the directory yet, but at least it will be possible to work around this issue for now.

I have seen this message for other gems that would have a C extension on CRuby, but skip building the extension on JRuby (falling back on a pure-Ruby or Java-based version). Something in RubyGems seems to get confused about whether an extension is or should be present: rubygems/rubygems#3520

If you are able to reproduce this consistently, you could report it there and maybe we will find a solution!

@headius Thanks so much for linking!

For what it's worth, I just started getting the following warning locally when running warbler specs:

Ignoring jruby-launcher-1.1.17-java because its extensions are not built. Try: gem pristine jruby-launcher --version 1.1.17

Running gem pristine jruby-laucher --version 1.1.7 fixed things for me.

The problem here was that when rubygems require checks for requirable files inside installed gems, it checks whether the gems being checked are missing extensions. If a gem is missing extensions, it's considered an ill-installed gem, and it's ignored.

In order to check whether a gem has extensions, rubygems checks the following: https://github.com/rubygems/rubygems/blob/56fd9e1275e9059ff7e9ef36e9f9a778c625320e/lib/rubygems/specification.rb#L2128-L2135.

  def missing_extensions?
    return false if default_gem?
    return false if extensions.empty?
    return false if File.exist? gem_build_complete_path
 
    true
  end

So:

  • Default gems are never missing extensions.
  • Gems without extensions are never missing extensions.
  • After correctly building extensions for a gem, rubygems leaves a "gem.build_complete" file at a well known location, to signal that installation of extensions succeeded. If this file is there, extensions are not missing.

In my case, the problem was that I migrated from java 11 to java 15, so the path of the gem.build_complete file changed from /home/deivid/.rbenv/versions/jruby-9.2.18.0/lib/ruby/gems/shared/extensions/universal-java-11/2.5.0/jruby-launcher-1.1.17-java/gem.build_complete to /home/deivid/.rbenv/versions/jruby-9.2.18.0/lib/ruby/gems/shared/extensions/universal-java-15/2.5.0/jruby-launcher-1.1.17-java/gem.build_complete, and thus was missing on java 15. gem pristine would rebulld the extension against the new java and put a new gem.build_complete file at the new location, that's why it fixed things.

In this case, however, it seems to me that the warning is more meaningful because it's indicating that the artifacts of building the extension are not being included in the packaged war.

Just reporting in case this could help.

This issue is still seen. Recently upgraded mimemagic to 0.4.3 but during application deployment, while accessing rake, below error was seen:
Bundler::GemNotFound: Could not find mimemagic-0.4.3 in any of the sources.

As a temporary solution, bundling the mimemagic-0.4.3.gem file with the application, re-installing the gem using this file & lastly doing local bundle install.

Any idea when can be done instead of this?