Skip to content

Bundler incorrect path resolution handling classloader URI #6045

@fzakaria

Description

@fzakaria

I have built a JAR using warbler where my Gemfile contains a gem using the :path argument.
The :path points to a sub-directory.

gem 'some-gem', :path => "ruby-gems/some-gem"

The gem is present (actually twice on account of jruby/warbler#465) in the built JAR:

jar -tf my-application.jar

gems/some-gem-1.0/
gems/some-gem-1.0/Gemfile
gems/some-gem-1.0/Gemfile.lock
gems/some-gem-1.0/some-gem.gemspec
gems/some-gem-1.0/lib/
gems/some-gem-1.0/lib/code.rb
gems/some-gem-1.0/test/
...
my-application/ruby-gems/some-gem/
my-application/ruby-gems/some-gem/Gemfile
my-application/ruby-gems/some-gem/Gemfile.lock
my-application/ruby-gems/some-gem/README.md
my-application/ruby-gems/some-gem/Rakefile
...

The JAR however fails to startup with the error: [!] There was an error parsing `Gemfile`: different prefix: "uri:classloader://" and "uri:classloader:/my-application". Bundler cannot continue.

You can find a small reproduction project: https://github.com/fzakaria/warbler-bundler-jruby-failure

bundle exec warble
java -jar warbler-example.jar

[!] There was an error parsing `Gemfile`: different prefix: "uri:classloader://" and "uri:classloader:/warbler-example". Bundler cannot continue.

 #  from uri:classloader:/warbler-example/Gemfile:4
 #  -------------------------------------------
 #  gem 'warbler', '2.0.5'
 >  gem 'jruby-jars', '9.1.17.0' #  ruby '2.3.3', engine: 'jruby', engine_version: '9.1.17.0'
 #  -------------------------------------------

The failure is present only once the following line is included:

require "bundler/setup"

Bundler 2.1.4 is needed to trigger the issue & I believe might be related to the commit rubygems/bundler@c7532ce
which introduced use of relative_path_from

Environment Information

Provide at least:

jruby 9.1.17.0 (2.3.3) 2018-04-20 d8b1ff9 OpenJDK 64-Bit Server VM 25.232-b09 on 1.8.0_232-b09 +jit [darwin-x86_64]

Darwin MacBook-Pro.localdomain 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64

Expected Behavior

Run the JAR built with warbler successfully.

Actual Behavior

eval_gemfile at uri:classloader:/gems/bundler-2.1.4/lib/bundler/dsl.rb:53
          evaluate at uri:classloader:/gems/bundler-2.1.4/lib/bundler/dsl.rb:12
             build at uri:classloader:/gems/bundler-2.1.4/lib/bundler/definition.rb:34
        definition at uri:classloader:/gems/bundler-2.1.4/lib/bundler.rb:195
             setup at uri:classloader:/gems/bundler-2.1.4/lib/bundler.rb:143
   block in (root) at uri:classloader:/gems/bundler-2.1.4/lib/bundler/setup.rb:20
        with_level at uri:classloader:/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:136
           silence at uri:classloader:/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:88
            <main> at uri:classloader:/gems/bundler-2.1.4/lib/bundler/setup.rb:20

[!] There was an error parsing `Gemfile`: different prefix: "uri:classloader://" and "uri:classloader:/my-application". Bundler cannot continue.

 #  from uri:classloader:/my-application/Gemfile:13
 #  -------------------------------------------
 #    end
 >  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions