如何在rails 3中安装插件,获取命令不是模块(TypeError)
我正在尝试将其安装为插件:
https://github.com/phatworx/rack_ip_restrictor
所以我跑:
$ rails plugin install git://github.com/phatworx/rack_ip_restrictor.git
这个错误:
/Users/userme/.rvm/gems/ruby-1.9.2-p180@andyw/gems/railties-3.0.5/lib/rails/commands/plugin.rb:277:in `': Commands is not a module (TypeError) from /Users/userme/.rvm/gems/ruby-1.9.2-p180@andyw/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require' from /Users/userme/.rvm/gems/ruby-1.9.2-p180@andyw/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `block in require' from /Users/userme/.rvm/gems/ruby-1.9.2-p180@andyw/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:in `block in load_dependency' from /Users/userme/.rvm/gems/ruby-1.9.2-p180@andyw/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:596:in `new_constants_in' from /Users/userme/.rvm/gems/ruby-1.9.2-p180@andyw/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:in `load_dependency' from /Users/userme/.rvm/gems/ruby-1.9.2-p180@andyw/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require' from /Users/userme/.rvm/gems/ruby-1.9.2-p180@andyw/gems/railties-3.0.5/lib/rails/commands.rb:17:in `' from script/rails:6:in `require' from script/rails:6:in `'
建议,想法? 谢谢
在GitHub上有一个解决方案 – 检查评论。
@acconrad是对的。 具体的解决方案是(如果你使用rails 3.0.9-和rake 0.9.2,你应该在需要’rake’之后添加包含Rake :: DSL到Rakefile。然后添加模块命令;在require’之前结束脚本/ rails rails / commands’,你不会再得到’命令不是模块(TypeError)’错误信息。):
在Rakefile中,
require File.expand_path('../config/application', __FILE__) require 'rake' # add this line of code include Rake::DSL
2.in script / rails:
APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) # add this line of code module Commands; end require 'rails/commands'
3.然后运行此命令:
$ bundle exec rails plugin install git://github.com/sbecker/asset_packager.git
该插件将被安装。
你试过rails 3.0.10吗? 它实际上应该与3.0.10一起使用!