Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Relative path on windows

#4238

Incorrect generator behaviour on Windows (it fails):

C:/ruby/lib/ruby/1.8/pathname.rb:709:in relative_path_from': different prefix:<br/> "C:/" and "D:/work/ruby/test" (ArgumentError)

    from C:/ruby/lib/ruby/gems/1.8/gems/radiant-0.8.1/vendor/rails/railties/lib/rails_generator/lookup.rb:110:in `use_component_sources!'
    from C:/ruby/lib/ruby/gems/1.8/gems/radiant-0.8.1/vendor/rails/railties/lib/rails_generator/lookup.rb:109:in `each'

...

System configuration:
Rails 2.3.5 + Ruby 1.8.6 + Win XP 32bit

Steps to reproduce:
1. Place ruby on a C: drive, place rails on a D: drive.
2. Use some generator tools.
3. Get the exception.

The root cause is in the lib/rails_generator/lookup.rb (line 110):
relative_path = Pathname.new(File.expand_path(path)).relative_path_from(Pathname.new(::RAILS_ROOT))

The relative_path_from raises an ArgumentError in the described case.
Workaround is to patch the lib/rails_generator/lookup.rb and catch the exception.
Dirty patch is to modify the 110 line in lib/rails_generator/lookup.rb:
begin
relative_path = Pathname.new(File.expand_path(path)).relative_path_from(Pathname.new(::RAILS_ROOT)) rescue ArgumentError
relative_path = Pathname.new(File.expand_path(path)) end

Reported by xelex · March 19th, 2010 @ 08:39 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. annoynmous
    annoynmous

    Виндовз не нужен. Закапывайте.

    March 30th, 2010 @ 10:21 PM

  2. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:44 PM

  3. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:44 PM