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.

rails:template Rake task does not expand file paths

#2528

Inconsistency:

rails -m ~/template.rb newapp works. rake rails:template LOCATION=~/template.rb does not.

AppGenerator uses OptionParser, which automatically expands file paths, before sending them on to TemplateRunner.

The "rails:template" Rake task, however, instantiates a TemplateRunner directly, passing it an ENV variable.

While the tilde will expand with rails -m, it will not expand for the Rake task, and instead will error out.

I've attached a patch that will expand file paths in the Rake task (not unlike what OptionParser does), scoping out URIs with the same regex open-uri uses.

Reported by Stephen Celis · April 20th, 2009 @ 05:23 PM

State: resolved
Milestone: 2.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Pratik
    Pratik
    • Title changed from [PATCH] rails:template Rake task does not expand file paths to rails:template Rake task does not expand file paths

    April 21st, 2009 @ 12:35 PM

  2. Pratik
    Pratik

    I tried rake rails:template LOCATION=~/template.rb and it works for me. Are you still facing this problem ?

    April 21st, 2009 @ 05:26 PM

  3. Stephen Celis
    Stephen Celis

    Yep. I can reproduce it on rails/master on 1.8.6 and 1.8.7, OS X, RedHat, and Ubuntu. It all goes back to File.open:

    >> File.open("~/real_file.rb")
    Errno::ENOENT: No such file or directory - ~/real_file.rb
    
    >> File.open(File.expand_path("~/real_file.rb"))
    => #<File:/Users/stephen/real_file.rb>
    
    

    OptionParser runs expand_path, but the Rake task does not.

    April 21st, 2009 @ 05:37 PM

  4. Pratik