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.

plugin_new_generator fails in `template': undefined method `today' for Date:Class (NoMethodError)

#6519

Hi

Using rails master and gems installed from rake install I tried to create a new mountable plugin with rails plugin new engine_test --mountable and the following error appeared.

active_support/time needs to be required for it to work.

Thanks

Reported by Steve Hodgkiss · March 4th, 2011 @ 11:18 AM

State: committed
Milestone: 3.1
Assigned to: Piotr Sarnacki Piotr Sarnacki
Importance: Low

Activity

  1. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open
    • Milestone set to 3.1
    • Assigned user set to Piotr Sarnacki
    • Importance changed from to Low

    Hey Piotr, can you take a look at this?

    March 4th, 2011 @ 02:18 PM

  2. Steve Hodgkiss
    Steve Hodgkiss
    • Tag changed from cli generators plugin_new to cli, generators, plugin_new

    Steps to reproduce:

    rvm gemset create 1.9.2@test
    rvm gemset use 1.9.2@test
    cd ~/code/rails
    rake install
    
    (in /Users/steve/code/rails)
    (in /Users/steve/code/rails/activesupport)
    (in /Users/steve/code/rails/activemodel)
    (in /Users/steve/code/rails/actionpack)
    (in /Users/steve/code/rails/actionmailer)
    (in /Users/steve/code/rails/activeresource)
    (in /Users/steve/code/rails/activerecord)
    (in /Users/steve/code/rails/railties)
    INSTALLING activesupport
    Successfully installed activesupport-3.1.0.beta
    1 gem installed
    INSTALLING activemodel
    Fetching: builder-3.0.0.gem (100%)
    Fetching: bcrypt-ruby-2.1.4.gem (100%)
    Building native extensions.  This could take a while...
    Successfully installed builder-3.0.0
    Successfully installed bcrypt-ruby-2.1.4
    Successfully installed activemodel-3.1.0.beta
    3 gems installed
    INSTALLING actionpack
    Fetching: rack-cache-1.0.gem (100%)
    Successfully installed rack-cache-1.0
    Successfully installed actionpack-3.1.0.beta
    2 gems installed
    INSTALLING actionmailer
    Successfully installed actionmailer-3.1.0.beta
    1 gem installed
    INSTALLING activeresource
    Successfully installed activeresource-3.1.0.beta
    1 gem installed
    INSTALLING activerecord
    Successfully installed activerecord-3.1.0.beta
    1 gem installed
    Successfully installed railties-3.1.0.beta
    1 gem installed
    ERROR:  Could not find a valid gem 'pkg/rails-3.1.0.beta.gem' (>= 0) in any repository
    
    gem build rails.gemspec
    gem install rails-3.1.0.beta.gem
    rails -v
    # => Rails 3.1.0.beta
    rails plugin new engine_test --mountable
          create  
          create  README.rdoc
          create  Rakefile
          create  engine_test.gemspec
          create  MIT-LICENSE
    (erb):1:in `template': undefined method `today' for Date:Class (NoMethodError)
        from /Users/steve/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/erb.rb:753:in `eval'
        from /Users/steve/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/erb.rb:753:in `result'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:111:in `block in template'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/actions/create_file.rb:54:in `call'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/actions/create_file.rb:54:in `render'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/actions/create_file.rb:63:in `block (2 levels) in invoke!'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/actions/create_file.rb:63:in `open'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/actions/create_file.rb:63:in `block in invoke!'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:114:in `call'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:114:in `invoke_with_conflict_check'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/actions/create_file.rb:61:in `invoke!'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/actions.rb:95:in `action'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/actions/create_file.rb:26:in `create_file'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:110:in `template'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@test/gems/railties-3.1.0.beta/lib/rails/generators/rails/app/app_generator.rb:15:in `method_missing'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@test/gems/railties-3.1.0.beta/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb:27:in `license'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@test/gems/railties-3.1.0.beta/lib/rails/generators/app_base.rb:85:in `build'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@test/gems/railties-3.1.0.beta/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb:156:in `create_root_files'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
        from /Users/steve/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
    

    March 5th, 2011 @ 02:05 PM

  3. jack dempsey (jackdempsey)
    jack dempsey (jackdempsey)

    I think this has been inadvertently solved by recent commits. I've seen the issue (had it just happen with a slightly old local install of 3.1.beta) but after going through things with a cleanly built gemset, no more errors.

    FWIW, you can also just require 'date' to get it to pass, if we do want to specifically add in a fix and not just rely on whatever else it was that changed it. Also, you might need to do "rvm gemset create engine_test; rvm use 1.9.2-p136@engine_test" depending on your version of rvm.

    HTH

    March 7th, 2011 @ 01:07 AM

  4. jack dempsey (jackdempsey)
    jack dempsey (jackdempsey)

    Course, as soon as I click submit and try it for real, busted again, as well as a different issue. Will look at it further, but either way, more eyes should take a look at this.

    March 7th, 2011 @ 01:16 AM

  5. Steve Hodgkiss
    Steve Hodgkiss

    Just tried it again on master, this is still an issue for me.

    Jack - you're right, require 'date' is all that is needed to fix this.

    March 7th, 2011 @ 01:29 AM

  6. jack dempsey (jackdempsey)
    jack dempsey (jackdempsey)

    Yep, tried it again, definitely still an issue. Found another one though--will open in a new ticket.

    March 7th, 2011 @ 03:34 AM

  7. Dave McPherson
    Dave McPherson

    I had the exact same issue. Running

    rake all:install
    

    resolved the problem.

    March 11th, 2011 @ 02:32 AM

  8. Dave McPherson
    Dave McPherson

    Err, that was for the "ERROR: Could not find a valid gem 'pkg/rails-3.1.0.beta.gem' (>= 0) in any repository" problem. Sorry.

    March 11th, 2011 @ 02:36 AM

  9. DHH