Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'rails new' creates a `validate_default_type!': An option's default must match its type. (ArgumentError) error

I am trying to create a new Ruby on Rails application. Every time I type in rails new after, I get this error

/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>' 

I have Ruby on Rails installed on my computer and have written other Ruby on Rails applications. Any ideas of why I am getting this error and how can I fix it?

like image 850
Aaron Avatar asked Nov 26 '16 21:11

Aaron


1 Answers

It seems the latest gem release broke it. Once that gets fixed, then this error should go away.

A temporary fix if you already have a Ruby on Rails app is to set the version of Thor in your Gemfile to the last release:

gem 'thor', '0.19.1'

Alternatively if you are having trouble creating a new Ruby on Rails application, you can uninstall Thor and install an older version:

gem uninstall thor
gem install thor -v 0.19.1
like image 58
excid3 Avatar answered Oct 04 '22 12:10

excid3