'rails new' creates `validate_default_type! ': the default parameter must match its type. (ArgumentError) error

I am trying to create a new Ruby on Rails application. Every time I type 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 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 on why I am getting this error and how to fix it?

+6
source share
4 answers

The latest gem release seems to have broken it. Once this is fixed, this error should disappear.

A temporary fix, if you already have a Ruby on Rails application, should install the Thor version in the Gemfile for the latest version:

 gem 'thor', '0.19.1' 

Otherwise, 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 
+3
source

I had the same problem, it turned out that I had to delete what was on my system and in my rails application.

I also could not create a new application, so on the command line I had to:

 gem uninstall thor gem install thor -v 0.19.1 

Then the rail commands work again on the command line

Then I generated a new rails application, but this did not succeed, as it received a broken version. So in my gem file I need the correct version:

 gem 'thor', '0.19.1' 

and then run

 bundle install 

Oh no!

 "You have requested: thor = 0.19.1 The bundle currently has thor locked at 0.19.2. Try running `bundle update thor`" 

so

 bundle update 

and voila !! :)

 Using thor 0.19.1 (was 0.19.2) 

And now the failing command is executed:

 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 
0
source

I just found that 0.19.3 has come out and is working now. I only play with rails for a week, so for those other beginners I didn’t find the ax links in the gemsfile in my application, but I just added it, as Benjamin showed, except for using 0.19.3, and updated the node and now it works. Everything else that I did before, from 0.19.1 gave me new rails, but then failed to create scaffolding.

0
source

I tried:

 gem install thor '0.19.1'. 

And I got:

Could not find a valid gem "0.19.1" (> = 0) in any repository.

Eric Michaels-Aubert changed the pearl of Thor. And rails new only works with Ruby on Rails v 5.0. And there are no old versions of this gem. Ruby on Rails now only works with version 5.0. Ruby on Rails 4.2.6 is over. Eric Michaels-Aubert and Gem Kill Old Ruby on Rails.
-one
source

Source: https://habr.com/ru/post/1012679/


All Articles