rails g 系統のコマンドが実行できない(2016/11/27から)

2016/11/27　からのエラー

前日に作成したアプリケーションは何事もなく動作するのに。。。


## 原因

今回は
rails g scaffold ~~~
でエラー。

試しに
rails g model ~~~
などを実行してもエラーが出た。


以下エラー文

```
Running via Spring preloader in process 3065
/var/lib/gems/2.3.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 /var/lib/gems/2.3.0/gems/thor-0.19.2/lib/thor/parser/option.rb:113:in `validate!'
	from /var/lib/gems/2.3.0/gems/thor-0.19.2/lib/thor/parser/argument.rb:24:in `initialize'
	from /var/lib/gems/2.3.0/gems/thor-0.19.2/lib/thor/parser/option.rb:9:in `initialize'
	from /var/lib/gems/2.3.0/gems/thor-0.19.2/lib/thor/base.rb:544:in `new'
	from /var/lib/gems/2.3.0/gems/thor-0.19.2/lib/thor/base.rb:544:in `build_option'
	from /var/lib/gems/2.3.0/gems/thor-0.19.2/lib/thor/base.rb:278:in `class_option'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/generators/base.rb:202:in `class_option'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/generators/base.rb:178:in `block in hook_for'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/generators/base.rb:168:in `each'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/generators/base.rb:168:in `hook_for'
	from /var/lib/gems/2.3.0/gems/jbuilder-2.6.0/lib/generators/rails/scaffold_controller_generator.rb:9:in `<class:ScaffoldControllerGenerator>'
	from /var/lib/gems/2.3.0/gems/jbuilder-2.6.0/lib/generators/rails/scaffold_controller_generator.rb:6:in `<module:Generators>'
	from /var/lib/gems/2.3.0/gems/jbuilder-2.6.0/lib/generators/rails/scaffold_controller_generator.rb:5:in `<module:Rails>'
	from /var/lib/gems/2.3.0/gems/jbuilder-2.6.0/lib/generators/rails/scaffold_controller_generator.rb:4:in `<top (required)>'
	from /var/lib/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
	from /var/lib/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
	from /var/lib/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
	from /var/lib/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
	from /var/lib/gems/2.3.0/gems/jbuilder-2.6.0/lib/jbuilder/railtie.rb:32:in `block in <class:Railtie>'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/railtie.rb:230:in `block in run_generators_blocks'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/railtie.rb:247:in `each'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/railtie.rb:247:in `each_registered_block'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/railtie.rb:230:in `run_generators_blocks'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/application.rb:453:in `block in run_generators_blocks'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/engine/railties.rb:13:in `each'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/engine/railties.rb:13:in `each'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/application.rb:453:in `run_generators_blocks'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/engine.rb:465:in `load_generators'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:144:in `generate_or_destroy'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:60:in `generate'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
	from /var/lib/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
	from /var/lib/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
	from /var/lib/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
	from /var/lib/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
	from /var/lib/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
	from /vagrant/WAC11/Endo_Diary5/bin/rails:9:in `<top (required)>'
	from /var/lib/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
	from /var/lib/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load'
	from /var/lib/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
	from /var/lib/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from -e:1:in `<main>'


```

検索したところ
どうやら
　gem 'thor', '0.19.0'
こいつが原因のようだ。

## 解決策
まず
/Gemfile　に
gem 'thor', '0.19.1'
こいつを追加


/Gemfile.lock

変更を加える
thor (>= 0.18.1, < 2.0)
↓
thor (0.19.1)


```
      activesupport (= 5.0.0.1)
      method_source
      rake (>= 0.8.7)
      thor (0.19.1)
    rake (11.3.0)
    rb-fsevent (0.9.8)
    rb-inotify (0.9.7)
      ffi (>= 0.5.0)
    responders (2.3.0)
      railties (>= 4.2.0, < 5.1)
    sass (3.4.22)
```

以下のコマンドを実行

```
$ gem uninstall thor
$ gem install thor -v 0.19.1
```

bundle update　thor しろと言われるので指示に従う。

今度は、bundle update を要求されたのでこれも実行

最後に念のため bundle install

これでなんとか解決した。


参考になれば幸いでござる。
　
いいねしてね。