GithubHelp home page GithubHelp logo

Comments (10)

fzakaria avatar fzakaria commented on June 2, 2024 1

@deivid-rodriguez I'll craft a repro project.
It needs to be done with JRuby and then packaged as a JAR.

I'll set up a repro project today.

from bundler.

fzakaria avatar fzakaria commented on June 2, 2024 1

@deivid-rodriguez I have produced a minimal example at https://github.com/fzakaria/warbler-bundler-jruby-failure

In order to reproduce it, please make sure you are using jruby
(I used rvm to install)

If you run the example script with simply ruby, it works.

bundle exec ruby bin/warbler-example.rb
>> Starting the JAR!
>> hello world

however, if you build the JAR & run it you get the error from above.

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'
 #  -------------------------------------------

from bundler.

fzakaria avatar fzakaria commented on June 2, 2024

Tracking this in JRuby issue also jruby/jruby#6045

from bundler.

deivid-rodriguez avatar deivid-rodriguez commented on June 2, 2024

Hello @fzakaria! Could you post exact repro instructions? I tried bundling a Gemfile including something like gem 'some-gem', :path => "ruby-gems/some-gem" and it worked, so there must be something else going on in your application.

from bundler.

deivid-rodriguez avatar deivid-rodriguez commented on June 2, 2024

I could reproduce the issue, thanks! I'll try to investigate it.

from bundler.

fzakaria avatar fzakaria commented on June 2, 2024

Great ! Let me know if you need anything else for help in the investigation.

from bundler.

deivid-rodriguez avatar deivid-rodriguez commented on June 2, 2024

Ok, so this seems like due to a weird inconsistency in jruby that should probably be fixed, where Pathname#expand_path with an argument always returns uri:classloader:// (double slash) as the canonical version of "uri:classloader" paths, while Pathname#expand_path without an argument always returns uri:classloader/ (single slash) as the canonical version of "uri:classloader" paths.

Pathname.new("uri:classloader://foo/bar").expand_path
#  => <Pathname:uri:classloader:/foo/bar>

Pathname.new("uri:classloader:/foo/bar").expand_path
# => <Pathname:uri:classloader:/foo/bar>

Pathname.new("foo/bar").expand_path("uri:classloader://")
# => <Pathname:uri:classloader://foo/bar>

Pathname.new("foo/bar").expand_path("uri:classloader:/")
# => <Pathname:uri:classloader://foo/bar>

That makes Pathname#relative_path_from explode because we end up passing to different "uri:classloader" kind of paths to it.

So, I see two things that can be fixed/changed in jruby:

  • Make Pathname#expand_path return consistent versions of "uri:classpath" paths.
  • Make Pathname#relative_path_from support different versions of "uri:classpath" paths, since they are both absolute paths after all.

As a workaround, I believe we can apply the following patch to bundler:

diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
index f98f5155fb..1aea7ece0d 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -132,7 +132,7 @@ module Bundler
       end
 
       def expand(somepath)
-        somepath.expand_path(root_path)
+        somepath.expand_path(root_path).expand_path
       rescue ArgumentError => e
         Bundler.ui.debug(e)
         raise PathError, "There was an error while trying to use the path " \

from bundler.

fzakaria avatar fzakaria commented on June 2, 2024

Since it's way less onerous to update Bundler gem vs updating our JRuby installation I would very much appreciate the patch to bundler to accommodate the bug.

I'll also add your latest investigation to jruby/jruby#6045 for them

from bundler.

deivid-rodriguez avatar deivid-rodriguez commented on June 2, 2024

Yes, we'll provide a workaround in bundler. I want to make sure I add a basic test for this in order to catch basic errors with warbler like this one in the future.

from bundler.

fzakaria avatar fzakaria commented on June 2, 2024

🙏 thanks.
Please feel free to tag me on the PR.

from bundler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.