gpt4 book ai didi

ruby-on-rails - 错误 "' Validate_default_type !': An option' s default must match its type (ArgumentError)"when running Ruby on Rails generate on Windows

转载 作者:数据小太阳 更新时间:2023-10-29 06:35:31 24 4
gpt4 key购买 nike

我正在关注 this tutorial并且刚刚开始。我已经使用 gem install rails 安装了 Ruby on Rails,并使用 rails new blog 创建了一个博客。

教程现在说我需要运行 rails generate controller Welcome index,但是当我这样做时,我得到了这个错误:

C:/Ruby22/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 C:/Ruby22/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/parser/option.rb:113:in `validate!'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/parser/argument.rb:24:in `initialize'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/parser/option.rb:9:in `initialize'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/base.rb:544:in `new'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/base.rb:544:in `build_option'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/base.rb:278:in `class_option'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/generators/base.rb:202:in `class_option'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/generators/base.rb:178:in `block in hook_for'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/generators/base.rb:168:in `each'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/generators/base.rb:168:in `hook_for'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/jbuilder-2.6.0/lib/generators/rails/scaffold_controller_generator.rb:9:in `<class:ScaffoldControllerGenerator>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/jbuilder-2.6.0/lib/generators/rails/scaffold_controller_generator.rb:6:in `<module:Generators>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/jbuilder-2.6.0/lib/generators/rails/scaffold_controller_generator.rb:5:in `<module:Rails>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/jbuilder-2.6.0/lib/generators/rails/scaffold_controller_generator.rb:4:in `<top (required)>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/jbuilder-2.6.0/lib/jbuilder/railtie.rb:32:in `block in <class:Railtie>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/railtie.rb:230:in `call'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/railtie.rb:230:in `block in run_generators_blocks'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/railtie.rb:247:in `each'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/railtie.rb:247:in `each_registered_block'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/railtie.rb:230:in `run_generators_blocks'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/application.rb:453:in `block in run_generators_blocks'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/engine/railties.rb:13:in `each'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/engine/railties.rb:13:in `each'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/application.rb:453:in `run_generators_blocks'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/engine.rb:465:in `load_generators'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:144:in `generate_or_destroy'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:60:in `generate'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

我在 Stack Overflow 上发现了一个类似的问题,询问同样的问题 here , 但当被要求显示他的 gem list 时,发布者从未回应。所以这是我的:

actioncable (5.0.0.1)
actionmailer (5.0.0.1)
actionpack (5.0.0.1)
actionview (5.0.0.1)
activejob (5.0.0.1)
activemodel (5.0.0.1)
activerecord (5.0.0.1)
activesupport (5.0.0.1)
arel (7.1.4)
bigdecimal (1.2.7, default: 1.2.6)
builder (3.2.2)
bundler (1.13.6)
coffee-rails (4.2.1)
coffee-script (2.4.1)
coffee-script-source (1.11.1)
concurrent-ruby (1.0.2)
debug_inspector (0.0.2)
erubis (2.7.0)
execjs (2.7.0)
globalid (0.3.7)
i18n (0.7.0)
io-console (0.4.6, default: 0.4.3)
jbuilder (2.6.0)
jquery-rails (4.2.1)
json (2.0.2, default: 1.8.1)
loofah (2.0.3)
mail (2.6.4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.9.1, 5.4.3)
multi_json (1.12.1)
nio4r (1.2.1)
nokogiri (1.6.8.1 x86-mingw32)
power_assert (0.3.1, 0.2.2)
psych (2.2.0, default: 2.0.8)
puma (3.6.2)
rack (2.0.1, 1.6.4)
rack-protection (1.5.3)
rack-test (0.6.3)
rails (5.0.0.1)
rails-dom-testing (2.0.1)
rails-html-sanitizer (1.0.3)
railties (5.0.0.1)
rake (11.3.0, default: 10.4.2)
rdoc (5.0.0, default: 4.2.0)
sass (3.4.22)
sass-rails (5.0.6)
sinatra (1.4.7)
sprockets (3.7.0)
sprockets-rails (3.2.0)
sqlite3 (1.3.12 x86-mingw32)
test-unit (3.2.3, 3.0.8)
thor (0.19.2, 0.19.1)
thread_safe (0.3.5)
tilt (2.0.5)
turbolinks (5.0.1)
turbolinks-source (5.0.0)
tzinfo (1.2.2)
tzinfo-data (1.2016.10)
uglifier (3.0.3)
web-console (3.4.0)
websocket-driver (0.6.4)
websocket-extensions (0.1.2)

有没有人遇到过这个错误?如果有,您是如何解决的?

最佳答案

临时修复是将您的 gemfile 中的 Thor 版本设置为最新版本。

gem 'thor', '0.19.1'

似乎最新的 gem 版本破坏了它。修复后,此错误应该会消失。

对于任何在创建新的 Ruby on Rails 应用程序或其他类似中间人时遇到问题的人,您可以卸载 Thor 并专门安装旧版本:

gem uninstall thor
gem install thor -v 0.19.1

关于ruby-on-rails - 错误 "' Validate_default_type !': An option' s default must match its type (ArgumentError)"when running Ruby on Rails generate on Windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40823526/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com