JRuby

relative_path_from returns errors for "C:/" and "C:\\"

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.2, JRuby 1.3RC1
  • Fix Version/s: JRuby 1.3RC2
  • Component/s: Core Classes/Modules
  • Labels:
    None
  • Environment:
    Windows XP, Java JRE6
  • Number of attachments :
    0

Description

This fails on Windows:
Pathname.new('C:/').relative_path_from(Pathname.new("C:
test"))

This came from my attempt to run script/generate during the RailsConf tutorial. Here's the full stack trace:

C:\cry>jruby -S script/generate controller test
c:/jruby/jruby-1.3.0RC1/bin/../lib/ruby/1.8/pathname.rb:711:in `relative_path_from': different prefix: "C:/" and "C:
cry" (Argument Error)
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator/lookup.rb:110:in `use_component_sources!'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator/lookup.rb:109:in `each'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator/lookup.rb:109:in `use_component_sources!'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator/lookup.rb:55:in `included'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator.rb:38
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator.rb:31:in `require'
from c:/jruby/jruby-1.3.0RC1/bin/../lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/generate.rb:2
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/generate.rb:31:in `require'
from c:/jruby/jruby-1.3.0RC1/bin/../lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from C:\cry\script\generate:3

Activity

Hide
Mark Donnelly added a comment -

Charles Nutter asked me to include this further debug output, which includes config/boot.rb outputting the value of RAILS_ROOT:

C:\cry>jruby script/generate migration blah2
"script/../config/.."
"C:/cry"
exists db/migrate
create db/migrate/20090504181152_blah2.rb

C:\cry>jruby -S script/generate migration blah2
"C:\\cry
script/../config/.."
"C:
cry"
c:/jruby/jruby-1.3.0RC1/bin/../lib/ruby/1.8/pathname.rb:711:in `relative_path_from': different prefix: "C:/" and "C:
cry" (Argument Error)
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator/lookup.rb:110:in `use_component_sources!'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator/lookup.rb:109:in `each'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator/lookup.rb:109:in `use_component_sources!'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator/lookup.rb:55:in `included'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator.rb:38
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator.rb:31:in `require'
from c:/jruby/jruby-1.3.0RC1/bin/../lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/generate.rb:2
from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/generate.rb:31:in `require'
from c:/jruby/jruby-1.3.0RC1/bin/../lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from C:\cry\script\generate:3

It looks like using the -S flag for the script/generate script was causing me problems.

Show
Mark Donnelly added a comment - Charles Nutter asked me to include this further debug output, which includes config/boot.rb outputting the value of RAILS_ROOT: C:\cry>jruby script/generate migration blah2 "script/../config/.." "C:/cry" exists db/migrate create db/migrate/20090504181152_blah2.rb C:\cry>jruby -S script/generate migration blah2 "C:\\cry
script/../config/.." "C:
cry" c:/jruby/jruby-1.3.0RC1/bin/../lib/ruby/1.8/pathname.rb:711:in `relative_path_from': different prefix: "C:/" and "C:
cry" (Argument Error) from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator/lookup.rb:110:in `use_component_sources!' from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator/lookup.rb:109:in `each' from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator/lookup.rb:109:in `use_component_sources!' from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator/lookup.rb:55:in `included' from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator.rb:38 from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails_generator.rb:31:in `require' from c:/jruby/jruby-1.3.0RC1/bin/../lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require' from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in' from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require' from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/generate.rb:2 from C:/jruby/jruby-1.3.0RC1/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/generate.rb:31:in `require' from c:/jruby/jruby-1.3.0RC1/bin/../lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from C:\cry\script\generate:3 It looks like using the -S flag for the script/generate script was causing me problems.
Hide
Charles Oliver Nutter added a comment -

I fixed and confirmed this on Windows...if you have a chance, I'd appreciate a simple test for this, probably added to test/test_command_line_switches.rb.

Show
Charles Oliver Nutter added a comment - I fixed and confirmed this on Windows...if you have a chance, I'd appreciate a simple test for this, probably added to test/test_command_line_switches.rb.
Hide
Charles Oliver Nutter added a comment -

FYI, the fix was to make sure -S processing normalizes paths to / just like everything else in JRuby. It was fixed in commit 87072bec63ec82a83f463417391ccc785870ec71.

Show
Charles Oliver Nutter added a comment - FYI, the fix was to make sure -S processing normalizes paths to / just like everything else in JRuby. It was fixed in commit 87072bec63ec82a83f463417391ccc785870ec71.
Hide
Dave Ray added a comment -

This may be related. If I run some of the script/ commands with the -C arguments (I'm using JRuby with rails.vim), I get a similar error:

>jruby -C C:\path\to\rails\app script/generate
C:/Program Files/jruby-1.3.1/bin/../lib/ruby/1.8/pathname.rb:711:in `relative_path_from':
different prefix: "C:/" and "C:
path/to/rails/app" (ArgumentError)
from C:/Program Files/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails_generator/lookup.rb:110:in
`use_component_sources!'

I'm using JRuby 1.3.1.

Similarly with script/console:

>jruby -C c:\path\to\rails\app script/console
Loading development environment (Rails 2.3.3)
C:/Program Files/jruby-1.3.1/bin/../lib/ruby/1.8/irb/init.rb:256:in `require': no such file to load – c:path/to/rails/app/config/environment (LoadError)
from C:/Program Files/jruby-1.3.1/bin/../lib/ruby/1.8/irb/init.rb:256:in `load_modules'
from C:/Program Files/jruby-1.3.1/bin/../lib/ruby/1.8/irb/init.rb:254:in
`each'
from C:/Program Files/jruby-1.3.1/bin/../lib/ruby/1.8/irb/init.rb:254:in
`load_modules'
from C:/Program Files/jruby-1.3.1/bin/../lib/ruby/1.8/irb/init.rb:21:in`setup'
from C:/Program Files/jruby-1.3.1/bin/../lib/ruby/1.8/irb.rb:54:in `start'
from C:\Program Files\jruby-1.3.1\bin\..\bin\jirb:19

Here, it looks like the first backslash after c: is dropped.

Adding -S is my current workaround, but from what I understand of -S, it shouldn't be necessary.

Show
Dave Ray added a comment - This may be related. If I run some of the script/ commands with the -C arguments (I'm using JRuby with rails.vim), I get a similar error: >jruby -C C:\path\to\rails\app script/generate C:/Program Files/jruby-1.3.1/bin/../lib/ruby/1.8/pathname.rb:711:in `relative_path_from': different prefix: "C:/" and "C:
path/to/rails/app" (ArgumentError) from C:/Program Files/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails_generator/lookup.rb:110:in `use_component_sources!' I'm using JRuby 1.3.1. Similarly with script/console: >jruby -C c:\path\to\rails\app script/console Loading development environment (Rails 2.3.3) C:/Program Files/jruby-1.3.1/bin/../lib/ruby/1.8/irb/init.rb:256:in `require': no such file to load – c:path/to/rails/app/config/environment (LoadError) from C:/Program Files/jruby-1.3.1/bin/../lib/ruby/1.8/irb/init.rb:256:in `load_modules' from C:/Program Files/jruby-1.3.1/bin/../lib/ruby/1.8/irb/init.rb:254:in `each' from C:/Program Files/jruby-1.3.1/bin/../lib/ruby/1.8/irb/init.rb:254:in `load_modules' from C:/Program Files/jruby-1.3.1/bin/../lib/ruby/1.8/irb/init.rb:21:in`setup' from C:/Program Files/jruby-1.3.1/bin/../lib/ruby/1.8/irb.rb:54:in `start' from C:\Program Files\jruby-1.3.1\bin\..\bin\jirb:19 Here, it looks like the first backslash after c: is dropped. Adding -S is my current workaround, but from what I understand of -S, it shouldn't be necessary.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: