我正在尝试创建一个新的Rails应用程序。每次我输入rails new之后,我都会得到这个错误
/usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/parser/option.rb:130:in `validate_default_type!': An option's default must match its type. (ArgumentError)
from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/parser/option.rb:113:in `validate!'
from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/parser/argument.rb:24:in `initialize'
from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/parser/option.rb:9:in `initialize'
from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/base.rb:544:in `new'
from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/base.rb:544:in `build_option'
from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/base.rb:278:in `class_option'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/base.rb:202:in `class_option'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/app_base.rb:71:in `add_shared_options_for'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/rails/app/app_generator.rb:160:in `<class:AppGenerator>'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/rails/app/app_generator.rb:159:in `<module:Generators>'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/rails/app/app_generator.rb:153:in `<module:Rails>'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/rails/app/app_generator.rb:3:in `<top (required)>'
from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/application.rb:2:in `<top (required)>'
from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/cli.rb:14:in `<top (required)>'
from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/bin/rails:9:in `<top (required)>'
from /usr/local/bin/rails:23:in `load'
from /usr/local/bin/rails:23:in `<main>' 我在我的计算机上安装了Rails,并编写了其他Rails应用程序。你知道我为什么会犯这个错误吗?我怎样才能修正它?
发布于 2016-11-26 22:07:15
似乎最新的创业板发行打破了它。一旦修复了这个错误,这个错误就会消失。
如果您已经有了Rails应用程序,那么一个临时的修复方法是将Gemfile中的Thor版本设置为最后一个版本:
gem 'thor', '0.19.1'或者,如果您在创建新的Rails应用程序时遇到问题,可以卸载Thor并安装一个旧版本:
gem uninstall thor
gem install thor -v 0.19.1发布于 2016-11-27 03:37:38
我也有同样的问题,结果我不得不在我的系统和我的rails应用程序中卸载thor。
我也无法在命令行中生成一个新的应用程序,所以我不得不:
gem uninstall thor
gem install thor -v 0.19.1然后,rails命令再次在命令行中工作。
然后,我生成了一个新的rails应用程序,但这失败了,因为它得到了坏的版本。因此,在我的gem文件中,我需要正确的版本:
gem 'thor', '0.19.1'然后跑
bundle install哦,不!
"You have requested:
thor = 0.19.1
The bundle currently has thor locked at 0.19.2.
Try running `bundle update thor`"所以呢?
bundle update 及瞧!)
Using thor 0.19.1 (was 0.19.2)失败的命令现在运行:
rails generate rspec:install
Running via Spring preloader in process 26996
create .rspec
create spec
create spec/spec_helper.rb
create spec/rails_helper.rb发布于 2016-11-27 19:56:14
我刚发现雷神0.19.3出局了,现在开始工作了。我只玩了一周rails,所以对于其他新手,我在我的应用程序中没有发现任何关于thor的引用,但我只是添加了它,本杰明展示了,除了使用0.19.3和包更新thor,它现在正在工作。我以前用0.19.1做的所有事情都给我带来了新的rails,但是在生成脚手架方面失败了。
https://stackoverflow.com/questions/40823471
复制相似问题