Thor Argument尝试创建新的Rails应用程序时出错

时间:2015-09-13 17:57:39

标签: ruby-on-rails ruby thor

我尝试使用rails-api创建新应用。当我运行rails-api new mynewapp时,我得到以下内容:

/Users/sandy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1.1/lib/thor/parser/option.rb:125:in `validate_default_type!': An option's default must match its type. (ArgumentError)
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1.1/lib/thor/parser/option.rb:111:in `validate!'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1.1/lib/thor/parser/argument.rb:24:in `initialize'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1.1/lib/thor/parser/option.rb:9:in `initialize'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1.1/lib/thor/base.rb:544:in `new'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1.1/lib/thor/base.rb:544:in `build_option'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1.1/lib/thor/base.rb:274:in `class_option'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/generators/base.rb:202:in `class_option'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/generators/app_base.rb:71:in `add_shared_options_for'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/generators/rails/app/app_generator.rb:160:in `<class:AppGenerator>'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/generators/rails/app/app_generator.rb:159:in `<module:Generators>'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/generators/rails/app/app_generator.rb:153:in `<module:Rails>'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/generators/rails/app/app_generator.rb:3:in `<top (required)>'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rails-api-0.4.0/lib/rails-api/generators/rails/app/app_generator.rb:2:in `<top (required)>'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /Users/sandy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rails-api-0.4.0/bin/rails-api:3:in `<top (required)>'
from /Users/sandy/.rbenv/versions/2.2.2/bin/rails-api:23:in `load'
from /Users/sandy/.rbenv/versions/2.2.2/bin/rails-api:23:in `<main>'

尝试rails new mynewapp时出现完全相同的错误,而不是

...gems/rails-api-0.4.0/bin/rails-api:3:in `<top (required)>'

我得到了

...gems/railties-4.2.4/bin/rails:9:in `<top (required)>'

即使运行rails -v也会出现同样的错误。

谷歌没有帮助。有谁知道可能导致这种情况的原因?

2 个答案:

答案 0 :(得分:0)

如果您运行rails -v并收到错误,那么您的安装可能很糟糕。我试着重新安装rails ...

关注此: http://installrails.com/

答案 1 :(得分:0)

看起来托尔0.19.1.1做了一个突破性的改变。尝试将其更改为0.19.1并查看是否可以解决问题。