Skip to content


Subversion checkout URL

You can clone with
Download ZIP


"rails plugin" command doesn't work with rake 0.9 #1866

rfc2822 opened this Issue · 35 comments

With this line in Gemfile:
require "rake"

$ rake -V
rake, version 0.9.2

all "rails plugin *" commands fail with this error:

/vendor/bundler/ruby/1.8/gems/railties-3.0.9/lib/rails/commands/plugin.rb:277: Commands is not a module (TypeError)
from /vendor/bundler/ruby/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in require'
from <my project path>/vendor/bundler/ruby/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in
from /vendor/bundler/ruby/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in load_dependency'
from <my project path>/vendor/bundler/ruby/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in
from /vendor/bundler/ruby/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in load_dependency'
from <my project path>/vendor/bundler/ruby/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in
from /vendor/bundler/ruby/1.8/gems/railties-3.0.9/lib/rails/commands.rb:17
from script/rails:6:in `require'
from script/rails:6

When using
gem 'rake', '0.8.7'

all "rails plugin" commands work.


What exactly are you trying to do? Do you have a Gemfile? The command below works fine.

rails plugin install git://

I tried to install a plugin with a command like yours, but every command that begins with
rails plugin
fails for me. Do you want to know if the project has a Gemfile? - Yes it has but its not related to the plugin. Shall I post the Gemfile?

@rfc2822 rfc2822 closed this
@rfc2822 rfc2822 reopened this

Had no intention to close this.... may i clicked the wrong button. re-opened


This is what I get when I run rails plugin install git:// Also includes running the commands bundle list and ls -R vendor. By the way, I'm running Ruby 1.9.2. I don't have the same issue. @CKIDOW, how about posting your app so anyone can pull it? @rfc2822, you should run the bundle list command and inform us what version of Ruby you're running.


(at the moment with rake 0.8.7 because I set the version in the Gemfile)
$ bundle list
Gems included by the bundle:

  • abstract (1.0.0)
  • actionmailer (3.0.9)
  • actionpack (3.0.9)
  • activemodel (3.0.9)
  • activerecord (3.0.9)
  • activeresource (3.0.9)
  • activesupport (3.0.9)
  • arel (2.0.10)
  • authlogic (3.0.2)
  • builder (2.1.2)
  • bundler (1.0.15)
  • capistrano (2.6.0)
  • erubis (2.6.6)
  • exception_notification_rails3 (1.2.0)
  • highline (1.6.2)
  • i18n (0.5.0)
  • mail (2.2.19)
  • meta-tags (1.2.3 96ae3d9)
  • mime-types (1.16)
  • net-scp (1.0.4)
  • net-sftp (2.0.5)
  • net-ssh (2.1.4)
  • net-ssh-gateway (1.1.0)
  • pg (0.11.0)
  • polyglot (0.3.1)
  • rack (1.2.3)
  • rack-mount (0.6.14)
  • rack-test (0.5.7)
  • rails (3.0.9)
  • railties (3.0.9)
  • rake (0.8.7)
  • rdoc (3.6.1)
  • ruby-graphviz (1.0.0)
  • rubyzip (0.9.4)
  • safeeval (0.0.1)
  • sqlite3 (1.3.3)
  • sqlite3-ruby (1.3.3)
  • state_machine (1.0.1)
  • thor (0.14.6)
  • treetop (1.4.9)
  • tzinfo (0.3.28)
  • validates_email_format_of (1.4.7)
  • will_paginate (3.0.pre3 b1a5bee) $ ruby -v ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2011.02

Ok, so you were using Ruby 1.8.7 p334 REE. I'll try that version of Ruby.


Getting this same issue with REE 1.8.7


I have the same issue in Ruby 1.9.2 p180. It doesn't happen in a fresh rails app, so it seems there's a gem somewhere that creating an object called Commands and causing rails plugin to fail. I will see if I can track down which gem it is.


I did a grep of my bundle for "Commands" and found that compass defines module Commands.

Rake 0.9.2 creates an object called "Commands":
./rake-0.9.2/lib/rake/dsl_definition.rb: Commands = DSL

If I track down what in Rails 3.0.9 is calling Commands, it's /railties-3.0.9/lib/rails/commands/plugin.rb:279

When I debug plugin.rb, Commands is a "Object", not a "Module", so my guess is that the rake dsl_definition Commands is already defined and thus when Rails tries to turn it into a module, it barfs.

The fact that Compass also has a module called Commands may also be an issue, but I doubt it.


Yeah, the issue is clearly that Rake object, just figured that out myself.

The issue could be fixed by modifying /railties-3.0.9/lib/rails/commands/plugin.rb to place Commands inside another module, although I would consider this to be a bug in Rake as well.


In the meantime, using a version of Rake earlier than 1.9.2 (1.9.1 is fine) fixes the problem


@mateomurphy, can you create a Rails app that has this issue? I can't recreate it.


simply including gem 'rake', '0.9.2' in a fresh rails app is enough to cause the issue for me


@mateomurphy, I included gem 'rake', '0.9.2' in my rails app's Gemfile and ran rake -T with no problems. Again, pushing a sample app to Github would prove tremendously helpful rather than ping-ponging back and forth like this.


rake -T works fine, it's rails plugin install git:// that won't work with rake 0.9.2 specified in the gem file. Are you able to get the rails plugin to work?

I could push a sample app, but as I've said the only thing I need to do to a fresh rails app to reproduce the error is add that line to the gemfile.


I have the same problem as @mateomurphy. Trying to downgrade rake to 1.8.7 as I don't need it at the moment. Not fun.


@phillipoertel, @mateomurphy, @MattRogish OK, I see the same thing too. I'm looking into it right now.


Cool, thanks!

@dyba dyba referenced this issue from a commit
@dyba dyba Changed Commands module to RailsCommands.
This is to avoid a conflict that occurs when you add Rake to
your Gemfile. There is a Commands Object in Rake that conflicts
with the Commands module in plugin.rb. See rails issue #1866.

Ok, this works now. I'll send it to the Rails core team for approval.

@dyba dyba referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.


@rfc2822 rfc2822 closed this

@dyba thanks so much for this fix. What's the best way to get this change in Rails 3.0.x? Is there a Gemfile line that should be added to pull this via git or another route you'd suggest?

EDIT: I've just gone ahead and forked Rails myself and then just added your patch as per: as that's about the best way I've seen how to do this so far.


@ylluminate If you use rails 3.0.9- with rake 0.9.2, you should add include Rake::DSL to Rakefile just after require 'rake'.
Then add module Commands; end to script/rails just before require 'rails/commands', you will not get 'Commands is not a module (TypeError)' error message any more.


What's going on with this issue? Still having problems in Rails 3.1 with this and rake 0.9.2


Dyba worked on a fix but it doesn't seem to have been applied, so I'm not sure why this is marked as closed


@aaronchi Rails 3.1.0 is fine with rake 0.9.2. It's the case of rails 3.0.9


I just reproduced this on 3.1. Only works if I add module Commands; end to script/rails as described in another post


@tsechingho's post worked for me on Rails 3.0.10 and rake 0.9.2... thanks!


@tsechingho's post also worked for Rails 3.0.3 and Rake 0.9.2. Thanks again for the help!


Still a problem for me with 3.1 and rake 0.9.2.


Thanks @tsechingho it worked for me. Using rails 3.0.10 rake 0.9.2


Still happening on 3.1.1 and rake 0.9.2 for me, as well. Adding the module Commands; end as indicated a few comments above fixed it for me. Based on other comments, I think this should be reopened for 3.1.1.


What happened to my fix? Boo. I'll take care of this.


@tsechingho -Thanks for the tips worked...

@tenderlove tenderlove referenced this issue from a commit
@dyba dyba Changed Commands module to RailsCommands.
This is to avoid a conflict that occurs when you add Rake to
your Gemfile. There is a Commands Object in Rake that conflicts
with the Commands module in plugin.rb. See rails issue #1866.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.