Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: JRuby 1.6RC3
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      This is a regression. Previous versions of jruby-complete.jar didn't percent-escape spaces in the paths.

      $ pwd
      /tmp
      $ java -jar jruby-complete.jar -v
      jruby 1.6.0.dev (ruby 1.8.7 patchlevel 249) (2010-12-29 ab3899a) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_22) [darwin-x86_64-java]
      $ java -jar jruby-complete.jar -r set -e 'p $LOAD_PATH'
      ["file:/private/tmp/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8", "file:/private/tmp/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared", "file:/private/tmp/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/1.8", "."]
      $ mkdir "path with spaces"
      $ mv jruby-complete.jar path\ with\ spaces
      $ java -jar path\ with\ spaces/jruby-complete.jar -r set -e 'p $LOAD_PATH'
      org.jruby.exceptions.RaiseException: (LoadError) no such file to load – set
      $ java -jar path\ with\ spaces/jruby-complete.jar -e 'p $LOAD_PATH'
      ["file:/private/tmp/path%20with%20spaces/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8", "file:/private/tmp/path%20with%20spaces/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared", "file:/private/tmp/path%20with%20spaces/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/1.8", "."]
      $

        Issue Links

          Activity

          Hide
          Charles Oliver Nutter added a comment -

          This now appears to be working for me from a master build. Can someone else confirm this using a jruby-complete.jar from http://ci.jruby.org/snapshots?

          ~/projects/jruby ➔ mkdir dir\ with\ spaces
          
          ~/projects/jruby ➔ mv jruby-complete.jar dir\ with\ spaces/
          
          ~/projects/jruby ➔ java -jar dir\ with\ spaces/jruby-complete.jar -r set -e 'p $LOAD_PATH'
          ["file:/Users/headius/projects/jruby/dir with spaces/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8", "file:/Users/headius/projects/jruby/dir with spaces/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared", "file:/Users/headius/projects/jruby/dir with spaces/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/1.8", "."]
          
          Show
          Charles Oliver Nutter added a comment - This now appears to be working for me from a master build. Can someone else confirm this using a jruby-complete.jar from http://ci.jruby.org/snapshots? ~/projects/jruby ➔ mkdir dir\ with\ spaces ~/projects/jruby ➔ mv jruby-complete.jar dir\ with\ spaces/ ~/projects/jruby ➔ java -jar dir\ with\ spaces/jruby-complete.jar -r set -e 'p $LOAD_PATH' ["file:/Users/headius/projects/jruby/dir with spaces/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8", "file:/Users/headius/projects/jruby/dir with spaces/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared", "file:/Users/headius/projects/jruby/dir with spaces/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/1.8", "."]
          Hide
          Charles Oliver Nutter added a comment -

          Also, FWIW, if there are still issues with jruby-rack, they should be filed separately. This issue was only about jruby-complete.jar standalone.

          Show
          Charles Oliver Nutter added a comment - Also, FWIW, if there are still issues with jruby-rack, they should be filed separately. This issue was only about jruby-complete.jar standalone.
          Hide
          Charles Oliver Nutter added a comment -

          See JRUBY-5337 for ongoing jruby-rack discussion. The most recent comments talk about issues running from within dirs with spaces.

          Show
          Charles Oliver Nutter added a comment - See JRUBY-5337 for ongoing jruby-rack discussion. The most recent comments talk about issues running from within dirs with spaces.
          Hide
          Syver Enstad added a comment -

          require_relative call from inside jruby-complete.jar fails when jruby-complete.jar is in a directory with spaces

          To reproduce:

          1. Make krypt.rb perform a require_relative which makes File.realpath raise in jruby 1.7.3 and makes require raise in 614ba113ee3e91168221bd3bb2c872f093dc9f63 (todays HEAD)

          Output from todays HEAD

          ~/.wine/drive_c/Program Files (x86)/flesk
          $ java -jar jruby-complete.jar -e "require 'krypt'"
          LoadError: no such file to load – jar:file:/home/syvensta/.wine/drive_c/Program%20Files%20(x86)/flesk/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/krypt_missing
          require at org/jruby/RubyKernel.java:1028
          require at jar:file:/home/syvensta/.wine/drive_c/Program%20Files%20(x86)/flesk/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36
          require_relative at file:/home/syvensta/.wine/drive_c/Program Files (x86)/flesk/jruby-complete.jar!/jruby/kernel19/kernel.rb:19
          (root) at jar:file:/home/syvensta/.wine/drive_c/Program%20Files%20(x86)/flesk/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/krypt.rb:37
          require at org/jruby/RubyKernel.java:1028
          (root) at jar:file:/home/syvensta/.wine/drive_c/Program%20Files%20(x86)/flesk/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1
          (root) at -e:1

          Output with 1.7.3 (actually I have patched HEAD with the 1.7.3 version of kernel.rb)
          ~/.wine/drive_c/Program Files (x86)/flesk
          $ java -jar jruby-complete.jar -e "require 'krypt'"
          Errno::ENOENT: No such file or directory - jar:file:/home/syvensta/.wine/drive_c/Program%20Files%20(x86)/flesk/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/krypt.rb
          realpath at org/jruby/RubyFile.java:763
          require_relative at file:/home/syvensta/.wine/drive_c/Program Files (x86)/flesk/jruby-complete.jar!/jruby/kernel19/kernel.rb:23
          (root) at jar:file:/home/syvensta/.wine/drive_c/Program%20Files%20(x86)/flesk/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/krypt.rb:37
          require at org/jruby/RubyKernel.java:1028
          (root) at jar:file:/home/syvensta/.wine/drive_c/Program%20Files%20(x86)/flesk/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1
          (root) at -e:1

          The problem seems to be that we pass an urlencoded url to the File class (RubyFile and friends) which they do not support.

          Show
          Syver Enstad added a comment - require_relative call from inside jruby-complete.jar fails when jruby-complete.jar is in a directory with spaces To reproduce: Make krypt.rb perform a require_relative which makes File.realpath raise in jruby 1.7.3 and makes require raise in 614ba113ee3e91168221bd3bb2c872f093dc9f63 (todays HEAD) Output from todays HEAD ~/.wine/drive_c/Program Files (x86)/flesk $ java -jar jruby-complete.jar -e "require 'krypt'" LoadError: no such file to load – jar: file:/home/syvensta/.wine/drive_c/Program%20Files%20(x86)/flesk/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/krypt_missing require at org/jruby/RubyKernel.java:1028 require at jar: file:/home/syvensta/.wine/drive_c/Program%20Files%20(x86)/flesk/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36 require_relative at file:/home/syvensta/.wine/drive_c/Program Files (x86)/flesk/jruby-complete.jar!/jruby/kernel19/kernel.rb:19 (root) at jar: file:/home/syvensta/.wine/drive_c/Program%20Files%20(x86)/flesk/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/krypt.rb:37 require at org/jruby/RubyKernel.java:1028 (root) at jar: file:/home/syvensta/.wine/drive_c/Program%20Files%20(x86)/flesk/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1 (root) at -e:1 Output with 1.7.3 (actually I have patched HEAD with the 1.7.3 version of kernel.rb) ~/.wine/drive_c/Program Files (x86)/flesk $ java -jar jruby-complete.jar -e "require 'krypt'" Errno::ENOENT: No such file or directory - jar: file:/home/syvensta/.wine/drive_c/Program%20Files%20(x86)/flesk/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/krypt.rb realpath at org/jruby/RubyFile.java:763 require_relative at file:/home/syvensta/.wine/drive_c/Program Files (x86)/flesk/jruby-complete.jar!/jruby/kernel19/kernel.rb:23 (root) at jar: file:/home/syvensta/.wine/drive_c/Program%20Files%20(x86)/flesk/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/krypt.rb:37 require at org/jruby/RubyKernel.java:1028 (root) at jar: file:/home/syvensta/.wine/drive_c/Program%20Files%20(x86)/flesk/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1 (root) at -e:1 The problem seems to be that we pass an urlencoded url to the File class (RubyFile and friends) which they do not support.
          Hide
          Syver Enstad added a comment -

          If we change require_relative in kernel.rb to decode the uri before passing it to the File methods my case seems to work fine. I am not sure if it is a good idea that
          the Kernel module depends on the URI class though, but it seems to me that either:

          • the RubyFile methods must support URI encoded uri's
          • require_relative must decode the uri's before passing them onward
          • the uri string that we get from caller.first at kernel.rb:14 should not contain an uri encoded value

          java -jar jruby-complete.jar -e "require 'krypt'; puts 'success'"
          success

          I wasn't able to attach anything to this issue so the patch is inline. (should I have cloned this issue or created another issue instead)
          – PATCH –

          From bbcc653bb47850171158776f15388a53858f04e5 Mon Sep 17 00:00:00 2001
          From: Syver Enstad <syver.enstad@cisco.com>
          Date: Wed, 24 Apr 2013 19:29:07 +0200
          Subject: [PATCH] Fix the require_relative issue


          src/jruby/kernel19/kernel.rb | 3 +++
          1 file changed, 3 insertions

          diff --git a/src/jruby/kernel19/kernel.rb b/src/jruby/kernel19/kernel.rb
          index ae2cbdf..ee8efe7 100644
          — a/src/jruby/kernel19/kernel.rb
          +++ b/src/jruby/kernel19/kernel.rb
          @@ -1,3 +1,5 @@
          +require 'uri'
          +
          module Kernel
          module_function
          def require_relative(relative_feature)
          @@ -15,6 +17,7 @@ module Kernel
          if /\A((.*))/ =~ file # eval, etc.
          raise LoadError, "cannot infer basepath"
          end
          + file = URI.decode(file)
          absolute_feature = File.expand_path(relative_feature, File.dirname(file))
          require absolute_feature
          end

          1.7.10.4

          Show
          Syver Enstad added a comment - If we change require_relative in kernel.rb to decode the uri before passing it to the File methods my case seems to work fine. I am not sure if it is a good idea that the Kernel module depends on the URI class though, but it seems to me that either: the RubyFile methods must support URI encoded uri's require_relative must decode the uri's before passing them onward the uri string that we get from caller.first at kernel.rb:14 should not contain an uri encoded value java -jar jruby-complete.jar -e "require 'krypt'; puts 'success'" success I wasn't able to attach anything to this issue so the patch is inline. (should I have cloned this issue or created another issue instead) – PATCH – From bbcc653bb47850171158776f15388a53858f04e5 Mon Sep 17 00:00:00 2001 From: Syver Enstad <syver.enstad@cisco.com> Date: Wed, 24 Apr 2013 19:29:07 +0200 Subject: [PATCH] Fix the require_relative issue — src/jruby/kernel19/kernel.rb | 3 +++ 1 file changed, 3 insertions diff --git a/src/jruby/kernel19/kernel.rb b/src/jruby/kernel19/kernel.rb index ae2cbdf..ee8efe7 100644 — a/src/jruby/kernel19/kernel.rb +++ b/src/jruby/kernel19/kernel.rb @@ -1,3 +1,5 @@ +require 'uri' + module Kernel module_function def require_relative(relative_feature) @@ -15,6 +17,7 @@ module Kernel if /\A((.*))/ =~ file # eval, etc. raise LoadError, "cannot infer basepath" end + file = URI.decode(file) absolute_feature = File.expand_path(relative_feature, File.dirname(file)) require absolute_feature end – 1.7.10.4

            People

            • Assignee:
              Charles Oliver Nutter
              Reporter:
              Jari Bakken
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: