问题
I'm trying to create a new app using rails-api
. When I run rails-api new mynewapp
I get the following:
/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>'
I get the exact same error when trying rails new mynewapp
, except instead of
...gems/rails-api-0.4.0/bin/rails-api:3:in `<top (required)>'
I get
...gems/railties-4.2.4/bin/rails:9:in `<top (required)>'
And even running rails -v
gives the same error.
Google was no help. Does anyone have any idea what might causing this?
回答1:
If you run rails -v
and get an error, your installation is probably bad. I'd try re-installing rails...
Follow this: http://installrails.com/
回答2:
It looks like thor 0.19.1.1 made a breaking change. Try changing it to 0.19.1 and see if that fixes the issue.
来源:https://stackoverflow.com/questions/32552782/thor-argument-error-when-trying-to-create-a-new-rails-app