JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6782

load path doesn't respect rubygems when invoked from command line

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: JRuby 1.7.0.pre2
    • Component/s: Launcher
    • Labels:
      None
    • Environment:
      jruby 1.6.7.2 (ruby-1.8.7-p357) (2012-05-01 26e08ba) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_33) [darwin-x86_64-java]
    • Number of attachments :
      0

      Description

      So this works:

      $ jruby --1.9 -e 'p require("rib")'
      true

      but not this one:

      $ jruby --1.9 -r rib -e 'p require("rib")'
      LoadError: no such file to load – rib

      Also, if I do this:

      $ jruby --1.9 -r rib

      It won't show up the LoadError until I input some strings.
      We could treat `-r` as calling `require` before executing the
      underlying program, so that it would be consistent.

      Not sure if there's other consideration though.

      The motivation behind this is I don't want to do this:

      $ jruby --1.9 -S bundler exec rake test

      but I want to do this:

      $ jruby --1.9 -r bundler/setup -S rake test

      to avoid launching multiple instances of Rubies.
      I know that JRuby has some tricks to avoid this,
      but the command to launch this test is for all rubies,
      I don't want to have a special case for JRuby.

      Hope this could be considered, thanks!

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        We seem to behave the same as MRI does now:

        # Working in 1.9 mode
        
        system ~/projects/jruby $ jruby -v -r rib -e "p require 'rib'"
        jruby 1.7.0.preview2.dev (ruby-1.9.3-p203) (2012-07-17 b4abf7c) (OpenJDK 64-Bit Server VM 1.8.0-internal) [darwin-x86_64-java]
        false
        
        system ~/projects/jruby $ rvm 1.9.3 do ruby -v -r rib -e "p require 'rib'"
        ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]
        false
        
        # Error in 1.8 mode
        
        system ~/projects/jruby $ jruby --1.8 -v -r rib -e "p require 'rib'"
        jruby 1.7.0.preview2.dev (ruby-1.8.7-p357) (2012-07-17 b4abf7c) (OpenJDK 64-Bit Server VM 1.8.0-internal) [darwin-x86_64-java]
        LoadError: no such file to load -- rib
        
        system ~/projects/jruby $ ruby -v -r rib -e "p require 'rib'"
        ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]
        ruby: no such file to load -- rib (LoadError)
        
        # Delayed error in stdin mode
        
        system ~/projects/jruby $ ruby -r rib
        puts 'hello'
        ruby: no such file to load -- rib (LoadError)
        
        system ~/projects/jruby $ jruby --1.8 -r rib
        puts 'hello'
        LoadError: no such file to load -- rib
        
        Show
        Charles Oliver Nutter added a comment - We seem to behave the same as MRI does now: # Working in 1.9 mode system ~/projects/jruby $ jruby -v -r rib -e "p require 'rib'" jruby 1.7.0.preview2.dev (ruby-1.9.3-p203) (2012-07-17 b4abf7c) (OpenJDK 64-Bit Server VM 1.8.0-internal) [darwin-x86_64-java] false system ~/projects/jruby $ rvm 1.9.3 do ruby -v -r rib -e "p require 'rib'" ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0] false # Error in 1.8 mode system ~/projects/jruby $ jruby --1.8 -v -r rib -e "p require 'rib'" jruby 1.7.0.preview2.dev (ruby-1.8.7-p357) (2012-07-17 b4abf7c) (OpenJDK 64-Bit Server VM 1.8.0-internal) [darwin-x86_64-java] LoadError: no such file to load -- rib system ~/projects/jruby $ ruby -v -r rib -e "p require 'rib'" ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0] ruby: no such file to load -- rib (LoadError) # Delayed error in stdin mode system ~/projects/jruby $ ruby -r rib puts 'hello' ruby: no such file to load -- rib (LoadError) system ~/projects/jruby $ jruby --1.8 -r rib puts 'hello' LoadError: no such file to load -- rib
        Hide
        Lin Jen-Shin added a comment -

        Excellent! Thank you. Sorry for not checking against trunk.

        Show
        Lin Jen-Shin added a comment - Excellent! Thank you. Sorry for not checking against trunk.

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Lin Jen-Shin
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: