Skip to content

Globbed jar contents with expand path failing in RubyGems #6060

@headius

Description

@headius

In #5996 we discovered that a RubyGems update seems to break our ability to use a jar file as a GEM_PATH.

The failures look like this:

TestJarredGemsWithSpacesInDirectory: 
  test_jarred_gem_on_gem_path:					E
================================================================================
org/jruby/RubyKernel.java:1187:in `catch'
org/jruby/RubyKernel.java:1192:in `catch'
org/jruby/RubyKernel.java:1187:in `catch'
org/jruby/RubyKernel.java:1192:in `catch'
     26:     Gem.clear_paths
     27:     old = ENV['GEM_PATH']
     28:     ENV['GEM_PATH'] = File.expand_path('../gem.jar', __FILE__)
  => 29:     assert require('mygem')
     30:   ensure
     31:     ENV['GEM_PATH'] = old
     32:     Gem.clear_paths
/home/travis/build/jruby/jruby/test/jruby/test_jarred_gems.rb:29:in `test_jarred_gem_on_gem_path'
/home/travis/build/jruby/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54:in `require'
org/jruby/RubyKernel.java:977:in `require'
Error: test_jarred_gem_on_gem_path(TestJarredGemsWithSpacesInDirectory): LoadError: no such file to load -- mygem
================================================================================
: (0.018789)
  test_list_gem_from_jar_with_spaces_in_directory:		F
================================================================================
org/jruby/RubyKernel.java:1187:in `catch'
org/jruby/RubyKernel.java:1192:in `catch'
org/jruby/RubyKernel.java:1187:in `catch'
org/jruby/RubyKernel.java:1192:in `catch'
      6: 
      7:   def test_list_gem_from_jar_with_spaces_in_directory
      8:     out = jruby(%q{-r"./test/jruby/dir with spaces/testgem.jar" -S jgem list})
  =>  9:     assert(out =~ /testgem/)
     10: 
     11:     cp = ENV['CLASSPATH']
     12:     begin
/home/travis/build/jruby/jruby/test/jruby/test_jarred_gems.rb:9:in `test_list_gem_from_jar_with_spaces_in_directory'
Failure: test_list_gem_from_jar_with_spaces_in_directory(TestJarredGemsWithSpacesInDirectory): <nil> is not true.
================================================================================

These failures are due to a change in ruby/rubygems@28c1f22 that modifies how gem paths are globbed to find gems and gemspecs.

The failure happens when doing one of two things and then trying to load a jarred gem:

  • Requiring a jar that contains a "GEM_PATH" style layout
  • Setting GEM_PATH to a jar that contains the appropriate layout

In each case, the "2.5" section in util.rb is the cause, and disabling that branch makes the jarred gem work correctly again.

A reduced script demonstrating the problem outside of RubyGems is here (using the test/jruby/gem.jar file in our repository:

glob = "*.gemspec"
base_path = "file:/Users/headius/projects/jruby/test/jruby/gem.jar!/specifications"

p Dir.glob(glob, base: base_path).map! {|f| File.expand_path(f, base_path) }
p Dir.glob(File.expand_path(glob, base_path))

The first glob is the one that fails, producing an empty array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions